PHPackages                             phpding/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. phpding/omnipay-unionpay

ActiveLibrary[Payment Processing](/categories/payments)

phpding/omnipay-unionpay
========================

UnionPay gateway for Omnipay payment processing library

v0.3.7(10y ago)191MITPHP

Since Aug 17Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (7)Used By (0)

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

[](#omnipay-unionpay)

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

[![Build Status](https://camo.githubusercontent.com/8a1139cda11ed94a697124a1ece2542d00d1fbf45156170409f3a1c6e94e5362/68747470733a2f2f7472617669732d63692e6f72672f6c6f6b69656c73652f6f6d6e697061792d756e696f6e7061792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/lokielse/omnipay-unionpay)[![Latest Stable Version](https://camo.githubusercontent.com/8fc71ec48a0bb736b4ebc7b8b7ea199e2084988c5dea8dc24482cae537656adc/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6b69656c73652f6f6d6e697061792d756e696f6e7061792f76657273696f6e2e706e67)](https://packagist.org/packages/lokielse/omnipay-unionpay)[![Total Downloads](https://camo.githubusercontent.com/37792cffe1127c930ec7adabc93d06f9ac30766af112b6cd2e47ac8da0aef68f/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6b69656c73652f6f6d6e697061792d756e696f6e7061792f642f746f74616c2e706e67)](https://packagist.org/packages/lokielse/omnipay-unionpay)

[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": {
        "lokielse/omnipay-unionpay": "dev-master"
    }
}
```

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\_Express (Union Express Checkout) 银联全产品网关（PC，APP，WAP支付）
- Union\_LegacyMobile (Union Legacy Mobile Checkout) 银联老网关（APP）
- Union\_LegacyQuickPay (Union Legacy QuickPay Checkout) 银联老网关（PC）

Usage
-----

[](#usage)

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

### Consume

[](#consume)

```
$gateway    = Omnipay::create('UnionPay_Express');
$gateway->setMerId($config['merId']);
$gateway->setCertPath($config['certPath']); // .pfx file
$gateway->setCertPassword($config['certPassword']);
$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
];

$response = $gateway->purchase($order)->send();

$response->getRedirectHtml(); //For PC/Wap
$response->getTradeNo(); //For APP
```

### Return/Notify

[](#returnnotify)

```
$gateway    = Omnipay::create('UnionPay_Express');
$gateway->setMerId($config['merId']);
$gateway->setCertDir($config['certDir']); //The directory contain *.cer files
$response = $gateway->completePurchase(['request_params'=>$_REQUEST])->send();
if ($response->isPaid()) {
    //pay success
}else{
    //pay fail
}
```

### Query Order Status

[](#query-order-status)

```
$response = $gateway->Omnipay::queryStatus([
    '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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92% 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 ~40 days

Recently: every ~50 days

Total

6

Last Release

3718d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4cd5bffd5be74413059af7c197f0dad2130519fe72782b09d13fea701d1fb74?d=identicon)[phpding](/maintainers/phpding)

---

Top Contributors

[![lokielse](https://avatars.githubusercontent.com/u/1573211?v=4)](https://github.com/lokielse "lokielse (23 commits)")[![phpding](https://avatars.githubusercontent.com/u/17756535?v=4)](https://github.com/phpding "phpding (2 commits)")

---

Tags

paymentgatewaypaymerchantomnipaypurchaseunionunionpay

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/phpding-omnipay-unionpay/health.svg)](https://phpackages.com/packages/phpding-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)
