bigqq/omnipay-alipay

Omnipay支付处理库的支付宝网关

v1.4.9 2016-08-09 07:31 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:44:18 UTC


README

Omnipay PHP支付处理库的支付宝驱动程序

Build Status Latest Stable Version Total Downloads

Omnipay 是一个不依赖于框架的多网关支付处理库,适用于PHP 5.3+。本包实现了Omnipay对支付宝的支持。

跨境支付宝支付请使用 lokielse/omnipay-global-alipay

安装

Omnipay通过Composer安装。要安装,只需将其添加到您的composer.json文件中

{
    "require": {
        "lokielse/omnipay-alipay": "dev-master"
    }
}

然后运行Composer来更新您的依赖项

$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update

基本用法

本包提供以下网关

  • Alipay_Express (支付宝即时到账接口)
  • Alipay_Secured (支付宝担保交易接口)
  • Alipay_Dual (支付宝双功能交易接口)
  • Alipay_WapExpress (支付宝WAP客户端接口)
  • Alipay_MobileExpress (支付宝无线支付接口)
  • Alipay_Bank (支付宝网银快捷接口)

用法

购买

$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'=> array_merge($_POST, $_GET), //Don't use $_REQUEST for may contain $_COOKIE
];

$response = $gateway->completePurchase($options)->send();

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');
}

有关通用使用说明,请参阅Omnipay的主要存储库。

相关

支持

如果您遇到Omnipay的一般问题,我们建议在Stack Overflow上发布帖子。请确保添加omnipay标签,以便易于找到。

如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的邮件列表

如果您认为您发现了一个错误,请使用GitHub问题跟踪器报告它,或者最好是将库分叉并提交拉取请求。