grimmlink/alipay-bundle
最新稳定版本:2.0
Composer 安装命令:
composer require grimmlink/alipay-bundle
包简介
GrimmlinkAlipayBundle
README 文档
README
A Symfony Bundle to help you create & submit payment using Alipay's Cross-border Website Payment system (http://global.alipay.com/product/websitepayment.htm)
Requirements
- cURL
- openssl
Installation
Installation with composer :
... "require": { ... "grimmlink/alipay-bundle": "dev-master", ... }, ...
Add this bundle to your app/AppKernel.php :
public function registerBundles() { return array( // ... new Grimmlink\AlipayBundle\GrimmlinkAlipayBundle(), // ... ); }
Configuration
Your personnal account informations must be set in your config.yml
# Grimmlink Alipay Bundle grimmlink_alipay: config: https_verify_url: https://mapi.alipay.net/gateway.do # The API endpoint key: 'abcdefghijklmnopqrstuvwxyz123456' # Your account key - alipay testing environment: 760bdzec6y9goq7ctyx96ezkz78287de parameters: partner: '1234567890123456' # Your partner number - alipay testing environment: 2088101122136241 currency: EUR # Cannot be CNY / RMB !! input_charset: utf-8 # service: create_forex_trade #
Routing
# Grimmlink Alipay Bundle grimmlink_alipay: resource: '@GrimmlinkAlipayBundle/Resources/config/routing.yml'
Usage
In your Payment controller :
... $apr = $this->get('grimmlink_alipay.request_handler'); $apr->setParameters(array( 'notify_url' => $this->generateUrl('grimmlink_alipay_notify', array(), true), 'return_url' => $this->generateUrl('payment_alipay_return', array(), true), // make it your own 'out_trade_no' => $ref, // make it your own 'total_fee' => '0.01', // make it your own 'subject' => 'Payment title', // make it your own 'body' => 'This is the payment description', // make it your own )); return $this->render('PaymentBundle:Alipay:pay.html.twig', array( 'url' => $apr->getUrl(), 'form' => $apr->getForm()->createView(), )); ...
Do not forget to create the controller action for your return URL, and do not include payment treatment inside, this is done in the Notification event listener.
Then, create your own Alipay Notification service listener, like this :
services: ... alipay.notification: class: Grimmlink\PaymentBundle\EventListener\AlipayListener tags: - { name: kernel.event_listener, event: alipay.notify_response, method: onAlipayNotificationResponse }
Create your Listener class and put your payment logic inside The AlipayResponseEvent contains
- data : the Query parameters sent by Alipay
- response : "true" if the notification has been validated
- signed : boolean - is the Alipay response's signature valid
统计信息
- 总下载量: 134
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-26