Alipay global driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Alipay support for Omnipay.
This package only support global Alipay service
Omnipay is installed via Composer. To install, simply add it to your composer.json
file:
{
"require": {
"lokielse/omnipay-global-alipay": "dev-master"
}
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
The following gateways are provided by this package:
/**
* @var Omnipay\GlobalAlipay\WebGateway $gateway
*/
//gateways: GlobalAlipay_Web, GlobalAlipay_Wap, GlobalAlipay_App
$gateway = Omnipay::create('GlobalAlipay_Web');
$gateway->setPartner('8888666622221111');
$gateway->setKey('your**key**here'); //for sign_type=MD5
$gateway->setPrivateKey($privateKeyPathOrData); //for sign_type=RSA
$gateway->setReturnUrl('http://www.example.com/return');
$gateway->setNotifyUrl('http://www.example.com/notify');
$gateway->setEnvironment('sandbox'); //for Sandbox Test (Web/Wap)
$params = [
'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
'currency' => 'USD', //default is 'USD'
];
/**
* @var Omnipay\GlobalAlipay\Message\WebPurchaseResponse $response
*/
$response = $gateway->purchase($params)->send();
//$response->redirect();
var_dump($response->getRedirectUrl());
var_dump($response->getRedirectData());
var_dump($response->getOrderString()); //for GlobalAlipay_App
/**
* @var Omnipay\GlobalAlipay\WebGateway $gateway
*/
$gateway = Omnipay::create('GlobalAlipay_Web');
$gateway->setPartner('8888666622221111');
$gateway->setKey('your**key**here'); //for sign_type=MD5
$gateway->setPrivateKey($privateKeyPathOrData); //for sign_type=RSA
$gateway->setEnvironment('sandbox'); //for Sandbox Test (Web/Wap)
$params = [
'request_params' => array_merge($_GET, $_POST), //Don't use $_REQUEST for may contain $_COOKIE
];
$response = $gateway->completePurchase($params)->send();
/**
* @var Omnipay\GlobalAlipay\Message\CompletePurchaseResponse $response
*/
if ($response->isPaid()) {
// Paid success, your statements go here.
//For notify, response 'success' only please.
//die('success');
} else {
//For notify, response 'fail' only please.
//die('fail');
}
For general usage instructions, please see the main Omnipay repository.
If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.
If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。