Home

Awesome

Omnipay: Alipay

travis Latest Version on Packagist Total Downloads Code Coverage Software License

Alipay driver for the Omnipay PHP payment processing library

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Alipay support for Omnipay.

Cross-border Alipay payment please use lokielse/omnipay-global-alipay

Legacy Version please use "lokielse/omnipay-alipay": "dev-legacy"

Installation

composer require lokielse/omnipay-alipay

Basic Usage

The following gateways are provided by this package:

GatewayDescription说明  Links
Alipay_AopPageAlipay Page Gateway电脑网站支付 - newUsage Doc
Alipay_AopAppAlipay APP GatewayAPP支付 - newUsage Doc
Alipay_AopF2FAlipay Face To Face Gateway当面付 - newUsage Doc
Alipay_AopWapAlipay WAP Gateway手机网站支付 - newUsage Doc
Alipay_AopJsAlipay Js GatewayJSAPI - newUsage Doc
Alipay_LegacyAppAlipay Legacy APP GatewayAPP支付Usage Doc
Alipay_LegacyExpressAlipay Legacy Express Gateway即时到账Usage Doc
Alipay_LegacyWapAlipay Legacy WAP Gateway手机网站支付Usage Doc

Usage

Purchase (购买)

/**
 * @var AopAppGateway $gateway
 */
$gateway = Omnipay::create('Alipay_AopPage');
$gateway->setSignType('RSA2'); // RSA/RSA2/MD5. Use certificate mode must set RSA2
$gateway->setAppId('the_app_id');
$gateway->setPrivateKey('the_app_private_key');
$gateway->setAlipayPublicKey('the_alipay_public_key'); // Need not set this when used certificate mode
$gateway->setReturnUrl('https://www.example.com/return');
$gateway->setNotifyUrl('https://www.example.com/notify');

// Must set cert path if you used certificate mode
//$gateway->setAlipayRootCert('the_alipay_root_cert'); // alipayRootCert.crt
//$gateway->setAlipayPublicCert('the_alipay_public_cert'); // alipayCertPublicKey_RSA2.crt
//$gateway->setAppCert('the_app_public_cert'); // appCertPublicKey.crt
//$gateway->setCheckAlipayPublicCert(true);

/**
 * @var AopTradePagePayResponse $response
 */
$response = $gateway->purchase()->setBizContent([
    'subject'      => 'test',
    'out_trade_no' => date('YmdHis') . mt_rand(1000, 9999),
    'total_amount' => '0.01',
    'product_code' => 'FAST_INSTANT_TRADE_PAY',
])->send();

$url = $response->getRedirectUrl();

For general usage instructions, please see the

Related

Support

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.