2017 © Pedro Peláez
 

library omnipay-alipay

增加了批量付款到支付宝账户和即时到帐批量退款接口的Omnipay支付宝接口

image

lonestonewy/omnipay-alipay

增加了批量付款到支付宝账户和即时到帐批量退款接口的Omnipay支付宝接口

  • Tuesday, August 16, 2016
  • by lonestonewy
  • Repository
  • 1 Watchers
  • 6 Stars
  • 68 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 101 Forks
  • 0 Open issues
  • 12 Versions
  • 8 % Grown

The README.md

Omnipay: Alipay

增加了批量付款到支付宝账户和即时到帐批量退款接口, (*1)

Build Status Latest Stable Version Total Downloads, (*2)

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Alipay support for Omnipay., (*3)

Cross-border Alipay payment please use lokielse/omnipay-global-alipay, (*4)

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:, (*5)

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

And run composer to update your dependencies:, (*6)

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

Basic Usage

The following gateways are provided by this package:, (*7)

  • 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) 支付宝网银快捷接口

基于lokielse的工作,增加了以下接口, (*8)

  • Alipay_BatchTrans (Alipay Express Checkout) 支付宝批量转账到支付宝账户接口
  • Alipay_RefundExpress (Alipay Express Checkout) 支付宝即时退款接口

Usage

Purchase

$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();

Return/Notify

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

批量付款到支付宝账户

$gateway    = Omnipay::create('Alipay_BatchTransGateway');
$gateway->setPartner('8888666622221111');
$gateway->setKey('your**key**here');
$gateway->setSellerEmail('merchant@example.com');
$gateway->setNotifyUrl('http://www.example.com/notify');

$detail_data = '流水号1^收款方账号1^收款账号姓名1^付款金额1^备注说明1|流水号2^收款方账号2^收款账号姓名2^付款金额2^备注说明2......';

$params = [
    'email'=>'merchant@example.com',
    'account_name'=>'merchant.name',
    'detail_data'=>$detail_data,
    'batch_no'=>$batch_no,//批号
    'batch_num'=>$batch_num,//笔数
    'batch_fee'=>$batch_fee,//总金额
    'pay_date'=>$pay_date,//付款日期
];
$response = $gateway->purchase($params)->send();

$redirect_url = $response->getRedirectUrl();

即时退款接口

该接口需要联系支付宝商服提前申请, (*9)

$gateway    = Omnipay::create('Alipay_RefundExpressGateway');
$gateway->setPartner('8888666622221111');
$gateway->setKey('your**key**here');
$gateway->setSellerEmail('merchant@example.com');
$gateway->setSignType('MD5');
$gateway->setInputCharset('UTF-8');
$gateway->setNotifyUrl('http://www.example.com/notify');

$data    = array(
    'refund_date' => date('Y-m-d H:i:s',time()),
    'batch_no'=>'1234567890',//退款编号
    'batch_num' => 1,//退款笔数
    'detail_data'=> mb_convert_encoding($this->alipay_trade_no.'^'.$amount.'^客户取消订单','GBK'),//退款数据,一次可以发起一批退款
);

$response = $gateway->refund($data)->send();
$debugData = $response->getData();

Yii::info('支付宝退款数据:'.print_r($debugData, true), 'payment');

if ($response->isSuccessful()) {
    //退款处理成功
}

上面的notify使用方法类似,具体可以参考支付宝文档,不再赘述。, (*10)

For general usage instructions, please see the main Omnipay repository., (*11)

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., (*12)

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., (*13)

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., (*14)

The Versions

16/08 2016

dev-master

9999999-dev https://github.com/lonestonewy/omnipay-alipay

增加了批量付款到支付宝账户和即时到帐批量退款接口的Omnipay支付宝接口

  Sources   Download

MIT

The Requires

 

The Development Requires

by lonestone

payment pay gateway merchant purchase omnipay alipay

16/08 2016

v2.0.0

2.0.0.0 https://github.com/lonestonewy/omnipay-alipay

增加了批量付款到支付宝账户和即时到帐批量退款接口的Omnipay支付宝接口

  Sources   Download

MIT

The Requires

 

The Development Requires

by lonestone

payment pay gateway merchant purchase omnipay alipay

09/08 2016

v1.4.9

1.4.9.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

19/01 2016

v1.4.8

1.4.8.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

15/09 2015

v1.4.7

1.4.7.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

18/08 2015

v1.4.6

1.4.6.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

17/08 2015

v1.4.5

1.4.5.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

17/08 2015

v1.4.0

1.4.0.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

16/08 2015

v1.3.0

1.3.0.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

16/08 2015

v1.2.0

1.2.0.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

25/07 2015

v1.0.1

1.0.1.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay

23/06 2015

v1.0.0

1.0.0.0 https://github.com/lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay alipay