PHPackages                             laravel-omnipay/omnipay-unionpay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. laravel-omnipay/omnipay-unionpay

ActiveLibrary[Payment Processing](/categories/payments)

laravel-omnipay/omnipay-unionpay
================================

UnionPay gateway for Omnipay payment processing library

v0.4.1(8y ago)0151MITPHP

Since Aug 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/laravel-omnipay/omnipay-unionpay)[ Packagist](https://packagist.org/packages/laravel-omnipay/omnipay-unionpay)[ Docs](https://github.com/lokielse/omnipay-unionpay)[ RSS](/packages/laravel-omnipay-omnipay-unionpay/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (12)Used By (1)

Omnipay: UnionPay
=================

[](#omnipay-unionpay)

[![Build Status](https://camo.githubusercontent.com/f34d11b03aee6617d7b8b18eacc537990adc43ae296b7530b199787821d4d3c4/68747470733a2f2f7472617669732d63692e6f72672f6c61726176656c2d6f6d6e697061792f6f6d6e697061792d756e696f6e7061792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/lokielse/omnipay-unionpay)[![Latest Stable Version](https://camo.githubusercontent.com/a15a01c6d9d6b7d6cb9130a31b33106d54db26e5553c53202a3bdec58559c4cc/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d6f6d6e697061792f6f6d6e697061792d756e696f6e7061792f76657273696f6e2e706e67)](https://packagist.org/packages/laravel-omnipay/omnipay-unionpay)[![Total Downloads](https://camo.githubusercontent.com/16590dc6fd1a3550e269e864606ddca7778b8dde3c3909d5cdbd0ec4ccb2856d/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d6f6d6e697061792f6f6d6e697061792d756e696f6e7061792f642f746f74616c2e706e67)](https://packagist.org/packages/laravel-omnipay/omnipay-unionpay)

**UnionPay driver for the Omnipay PHP payment processing library**

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements UnionPay support for Omnipay.

Installation
------------

[](#installation)

Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file:

```
{
    "require": {
        "laravel-omnipay/omnipay-unionpay": "^3.0"
    }
}
```

And run composer to update your dependencies:

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

```

Basic Usage
-----------

[](#basic-usage)

The following gateways are provided by this package:

- 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
-----

[](#usage)

Sandbox Param can be found at: [UnionPay Developer Center](https://open.unionpay.com/ajweb/account/testPara)

Prepare
-------

[](#prepare)

How to get `PrivateKey`, `PublicKey`, `Cert ID`:

```
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

[](#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

[](#returnnotify)

```
$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

[](#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

[](#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

[](#refund)

```
$response = $gateway->refund([
    '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());
```

### File Transfer

[](#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](https://github.com/omnipay/omnipay)repository.

Related
-------

[](#related)

- [Laravel-Omnipay](https://github.com/ignited/laravel-omnipay)
- [Omnipay-Alipay](https://github.com/lokielse/omnipay-alipay)
- [Omnipay-WechatPay](https://github.com/lokielse/omnipay-wechatpay)

Support
-------

[](#support)

If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) 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](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/lokielse/omnipay-unionpay/issues), or better yet, fork the library and submit a pull request.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 91.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~79 days

Recently: every ~88 days

Total

11

Last Release

3123d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15796287?v=4)[bigrocs](/maintainers/bigrocs)[@bigrocs](https://github.com/bigrocs)

---

Top Contributors

[![lokielse](https://avatars.githubusercontent.com/u/1573211?v=4)](https://github.com/lokielse "lokielse (68 commits)")[![bigrocs](https://avatars.githubusercontent.com/u/15796287?v=4)](https://github.com/bigrocs "bigrocs (6 commits)")

---

Tags

paymentgatewaypaymerchantomnipaypurchaseunionunionpay

### Embed Badge

![Health badge](/badges/laravel-omnipay-omnipay-unionpay/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-omnipay-omnipay-unionpay/health.svg)](https://phpackages.com/packages/laravel-omnipay-omnipay-unionpay)
```

###  Alternatives

[lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

11358.1k2](/packages/lokielse-omnipay-unionpay)[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
