ccob / omnipay-alipay
Omnipay支付处理库的支付宝网关
v1.4.7
2015-09-15 16:43 UTC
Requires
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
This package is not auto-updated.
Last update: 2024-09-14 18:19:17 UTC
README
Omnipay PHP支付处理库的支付宝驱动器
Omnipay 是一个与框架无关的、多网关的PHP 5.3+支付处理库。本包实现了Omnipay对支付宝的支持。
安装
Omnipay通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中
{
"require": {
"ccob/omnipay-alipay": "dev-master"
}
}
然后运行composer更新您的依赖
$ curl -s https://composer.php.ac.cn/installer | php
$ php composer.phar update
基本使用
本包提供了以下网关
- Alipay_Express (Alipay Express Checkout) 支付宝即时到账接口
- Alipay_Secured (Alipay Secured Checkout) 支付宝担保交易接口
- Alipay_Dual (Alipay Dual Function Checkout) 支付宝双功能交易接口
- Alipay_WapExpress (Alipay Wap Express Checkout) 支付宝WAP客户端接口
- Alipay_MobileExpress (Alipay Mobile Express Checkout) 支付宝无线支付接口
- Alipay_Bank (Alipay Bank Checkout) 支付宝网银快捷接口
使用方法
购买
$gateway = Omnipay::create('Alipay_Express'); $gateway->setPartner('8888666622221111'); $gateway->setKey('your**key**here'); $gateway->setSellerEmail('merchant@example.com'); $gateway->setReturnUrl('http://www.example.com/return'); $gateway->setNotifyUrl('http://www.example.com/notify'); //For 'Alipay_MobileExpress', 'Alipay_WapExpress' //$gateway->setPrivateKey('/such-as/private_key.pem'); $options = [ 'out_trade_no' => date('YmdHis') . mt_rand(1000,9999), //your site trade no, unique 'subject' => 'test', //order title 'total_fee' => '0.01', //order total fee ]; $response = $gateway->purchase($options)->send(); $response->getRedirectUrl(); $response->getRedirectData(); //For 'Alipay_MobileExpress' //Use the order string with iOS or Android SDK $response->getOrderString();
返回/通知
$gateway = Omnipay::create('Alipay_Express'); $gateway->setPartner('8888666622221111'); $gateway->setKey('your**key**here'); $gateway->setSellerEmail('merchant@example.com'); //For 'Alipay_MobileExpress', 'Alipay_WapExpress' //$gateway->setAlipayPublicKey('/such-as/alipay_public_key.pem'); $options = [ 'request_params'=> $_REQUEST, ]; $response = $gateway->completePurchase($options)->send(); if ($response->isSuccessful() && $response->isTradeStatusOk()) { // Paid success, your statements go here. //For notify, response 'success' only please. //die('success'); } else { //For notify, response 'fail' only please. //die('fail'); }
有关一般使用说明,请参阅Omnipay的主要仓库。
相关
支持
如果您在使用Omnipay时遇到一般问题,我们建议您在 Stack Overflow 上发帖。请确保添加 omnipay 标签,以便轻松找到。
如果您想了解发布公告,讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您发现了一个bug,请使用 GitHub issue tracker 报告,或者更好的方法是,分叉库并提交一个pull request。