chub / interkassa-bundle
此软件包最新版本(dev-master)无可用许可证信息。
将interkassa支付系统集成到您的Symfony2项目的软件包
dev-master / 2.2.x-dev
2013-05-11 09:27 UTC
Requires
- php: >=5.3
- symfony/form: >=2.1
- symfony/framework-bundle: >=2.1, <2.3.*-dev
- symfony/twig-bundle: >=2.1
- symfony/yaml: >=2.1
- twig/extensions: 1.0.*
- twig/twig: >=1.5
Requires (Dev)
- symfony/browser-kit: >=2.1
- symfony/class-loader: >=2.1
- symfony/css-selector: >=2.1
- symfony/finder: 2.*
This package is not auto-updated.
Last update: 2024-09-14 13:18:07 UTC
README
Symfony2 InterkassaBundle 允许我们通过Interkassa系统获取用户支付。 Interkassa是俄罗斯和乌克兰最大的支付系统集成商之一。
安装
使用composer
将 "chub/interkassa-bundle": "*"
添加到 composer.json 文件的 required
部分,并运行 php composer.phar update
。
注册您的软件包
将其添加到您的内核中
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new ChubProduction\InterkassaBundle\InterkassaBundle(), ); // ... }
配置
将interkassa部分添加到您的 app\config.yml
interkassa: connections: # contain shop descriptions intercassa: shop_id: ololo # Shop id (you can get it in your profile) secret_key: ololo # Secret key (you can get it in your profile) fail_url: /profile/balance # Url to redirect user on transaction fail success_url: /profile/balance # Url to redirect user on transaction success #another_shop: # ....
添加一些路由
payment_status: pattern: /payment/status/{connection} defaults: { _controller: InterkassaBundle:Payment:status } payment_success: pattern: /payment/success/{connection} defaults: { _controller: InterkassaBundle:Payment:success } payment_fail: pattern: /payment/fail/{connection} defaults: { _controller: InterkassaBundle:Payment:fail }
用法
- 创建您的支付项类
<?php //.. use ChubProduction\InterkassaBundle\Entity\Payment; use ChubProduction\InterkassaBundle\Service\PaymentItemInterface; class PaymentItem implements PaymentItemInterface { public function getAmount() { // return '1.00'; } public function getDescription() { // return 'ololo'; } public function setPayment(Payment $p) { // TODO: Implement setPayment() method. } }
- 创建一个支付对象
$po = new PaymentItem();
- 将用户重定向到支付
// Somewhere in your Action $response = $this->get('payment')->createInvoice($po, 'intercassa'); return $response
- 检查支付状态
$po->getPayment()->isPaid();
事件系统
您还可以注册自己的事件订阅者/分发器来处理发票创建、成功或失败的交易。为此,有 InterkassaPaymentEvent
对象和 InterkassaPaymentEvent::ON_INVOICE
、InterkassaPaymentEvent::ON_STATUS_SUCCESS
、InterkassaPaymentEvent::ON_STATUS_FAIL
事件。