rodgermd / sofort2-bundle
Symfony 2 集成包,用于 sofort 支付 PHP 库
v0.3.2
2014-09-24 06:29 UTC
Requires
- rodgermd/sofort2-lib: @stable
This package is not auto-updated.
Last update: 2024-09-14 15:32:20 UTC
README
Symfony2 集成包用于 Sofort PHP 库 2.x 版本
安装
添加集成包
AppKernel.php
public function registerBundles() { $bundles = array( ... new Sofort\SofortBundle(), ... }
添加控制器路由
routing.yml
sofort_controller: resource: "@SofortBundle/Controller/" type: annotation prefix: /sofort
可选:添加测试配置键
parameters.yml
sofort: test_key: 'XXX:XXX:XXXXXXXXXXXX'
使用
管理器
$manager = $container->get('sofort.manager') $manager->setConfigKey($sofortConfigKey);
请求创建交易
// Prepares model $model = new PaymentRequestModel(); $model ->setAmount(0.1) ->setReason('test reason') ->setCountry('DE') ->setName('Max Mustermann') ->setAccountNumber('88888888') ->setBankCode('12345678'); // Call manager $event = $manager->createTransaction($model);
调用 $manager->createTransaction($model) 时,将触发 'sofort.transaction.created' 事件,并带有 TransactionCreateEvent 参数。
该参数包含 $response 和 $transactionId 属性
请求交易详情
$response = $manager->requestTransaction($transactionId);
$response 是 SofortLibTransactionData 实例。
成功获取详情后,将触发 SofortEvents::DETAILS 事件,并带有 TransactionDetailsEvent 参数
SofortLibTransactionData 方法
- getAmount
- getAmountRefunded
- getCount
- getPaymentMethod
- getConsumerProtection
- getStatus
- getStatusReason
- getStatusModifiedTime
- getLanguageCode
- getCurrency
- getTransaction
- getReason
- getUserVariable
- getTime
- getProjectId
- getRecipientHolder
- getRecipientAccountNumber
- getRecipientBankCode
- getRecipientCountryCode
- getRecipientBankName
- getRecipientBic
- getRecipientIban
- getSenderHolder
- getSenderAccountNumber
- getSenderBankCode
- getSenderCountryCode
- getSenderBankName
- getSenderBic
- getSenderIban