2017 © Pedro Peláez
 

library omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

image

lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  • Monday, May 21, 2018
  • by waisir
  • Repository
  • 7 Watchers
  • 74 Stars
  • 7,808 Installations
  • PHP
  • 3 Dependents
  • 3 Suggesters
  • 24 Forks
  • 4 Open issues
  • 16 Versions
  • 8 % Grown

The README.md

Omnipay: UnionPay

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

UnionPay driver for the Omnipay PHP payment processing library, (*2)

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

Installation

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

{
    "require": {
        "lokielse/omnipay-unionpay": "^0.4"
    }
}

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

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

Basic Usage

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

  • Union_Wtz (Union No Redirect Payment) 银联无跳转支付(alpha)
  • Union_Express (Union Express Payment) 银联全产品网关(PC,APP,WAP支付)
  • Union_LegacyMobile (Union Legacy Mobile Payment) 银联老网关(APP)
  • Union_LegacyQuickPay (Union Legacy QuickPay Payment) 银联老网关(PC)

Usage

Sandbox Param can be found at: UnionPay Developer Center, (*7)

Prepare

How to get PrivateKey, PublicKey, Cert ID:, (*8)

0. Prepare cert.pfx and its password, verify_sign_acp.cer

1. Get Private Key
$ openssl pkcs12 -in cert.pfx  -nocerts -nodes | openssl rsa -out private_key.pem

2. Public key is verify_sign_acp.cer

3. Get Cert ID
$ openssl pkcs12 -in cert.pfx -clcerts -nokeys | openssl x509 -serial -noout // result hex eg: XXXXXXXXXX
$ visit https://lokielse.github.io/hex2dec //Convert hex to decimal online

Consume

$gateway    = Omnipay::create('UnionPay_Express');
$gateway->setMerId($config['merId']);
$gateway->setCertId($config['certId']);
$gateway->setPrivateKey($config['privateKey']); // path or content
$gateway->setReturnUrl($config['returnUrl']);
$gateway->setNotifyUrl($config['notifyUrl']);

$order = [
    'orderId'   => date('YmdHis'), //Your order ID
    'txnTime'   => date('YmdHis'), //Should be format 'YmdHis'
    'orderDesc' => 'My order title', //Order Title
    'txnAmt'    => '100', //Order Total Fee
];

//For PC/Wap
$response = $gateway->purchase($order)->send();
$response->getRedirectHtml();

//For APP
$response = $gateway->createOrder($order)->send();
$response->getTradeNo();

Return/Notify

$gateway    = Omnipay::create('UnionPay_Express');
$gateway->setMerId($config['merId']);
$gateway->setPublicKey($config['publicKey']); // path or content

$response = $gateway->completePurchase(['request_params'=>$_REQUEST])->send();

if ($response->isPaid()) {
    //pay success
}else{
    //pay fail
}

Query Order Status

$response = $gateway->query([
    'orderId' => '20150815121214', //Your site trade no, not union tn.
    'txnTime' => '20150815121214', //Order trade time
    'txnAmt'  => '200', //Order total fee
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

Consume Undo

$response = $gateway->consumeUndo([
    'orderId' => '20150815121214', //Your site trade no, not union tn.
    'txnTime' => date('YmdHis'), //Regenerate a new time
    'txnAmt'  => '200', //Order total fee
    'queryId' => 'xxxxxxxxx', //Order total fee
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

Refund

// 注意:
1. 银联退款时,必须加上 queryId, 
2. 作为商户生成的订单号orderId与退款时的订单号是不一样的。也就意味着退款时的订单号必须重新生成。
3. txnAmt 这个参数银联是精确到分的。直接返回元为单位的值,将会出现报错信息。
// get the queryId first
$response = $gateway->query([
    'orderId' => '20150815121214', //Your site trade no, not union tn.
    'txnTime' => '20150815121214', //Order trade time
    'txnAmt'  => 200 * 100, //Order total fee; notice that: you should multiply the txnAmt by 100 with the Unionpay gateway. Such as 200 * 100;
])->send();
$queryId = ($response->getData())['queryId'];
$response = $gateway->refund([
    'orderId' => '20150815121214', //Your site trade no, not union tn. notice: this orderId must not be the same with the order's created orderId.
    'txnTime' => date('YmdHis'), //Order trade time
    'txnAmt'  => 200 * 100, //Order total fee; notice that: you should multiply the txnAmt by 100 with the Unionpay gateway. Such as 200 * 100;
    'queryId' => $queryId
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

File Transfer

$response = $gateway->fileTransfer([
    'txnTime'    => '20150815121214', //Order trade time
    'settleDate' => '0119', //Settle Date
    'fileType'   => '00', //File Type
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

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

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

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

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

The Versions

21/05 2018

dev-master

9999999-dev https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel payment pay gateway merchant purchase omnipay sdk union unionpay 银联 无跳转支付

21/05 2018

v3.0.3

3.0.3.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel payment pay gateway merchant purchase omnipay sdk union unionpay 银联 无跳转支付

24/04 2018

v3.0-beta.1

3.0.0.0-beta1 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel payment pay gateway merchant purchase omnipay sdk union unionpay 银联 无跳转支付

24/04 2018

dev-develop

dev-develop https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel payment pay gateway merchant purchase omnipay sdk union unionpay 银联 无跳转支付

30/03 2018

v3.0-alpha.1

3.0.0.0-alpha1 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel payment pay gateway merchant purchase omnipay sdk union unionpay 银联 无跳转支付

23/10 2017

v0.3.10

0.3.10.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

23/10 2017

v0.3.9

0.3.9.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

20/10 2017

v0.4.1

0.4.1.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

17/10 2017

v0.4.0

0.4.0.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

02/11 2016

v0.3.8

0.3.8.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

03/03 2016

v0.3.7

0.3.7.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

18/08 2015

v0.3.6

0.3.6.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

17/08 2015

v0.3.5

0.3.5.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

17/08 2015

v0.3.0

0.3.0.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

17/08 2015

v0.2.0

0.2.0.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联

17/08 2015

v0.1.0

0.1.0.0 https://github.com/lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

payment pay gateway merchant purchase omnipay union unionpay 银联