PHPackages                             zhangv/union-pay - 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. zhangv/union-pay

ActiveLibrary[Payment Processing](/categories/payments)

zhangv/union-pay
================

The simplest union pay

v0.8.13(6y ago)327.2k17[1 issues](https://github.com/zhangv/union-pay/issues)1MITPHPPHP &gt;=5.6CI failing

Since May 9Pushed 5y ago3 watchersCompare

[ Source](https://github.com/zhangv/union-pay)[ Packagist](https://packagist.org/packages/zhangv/union-pay)[ Docs](https://github.com/zhangv/union-pay)[ RSS](/packages/zhangv-union-pay/feed)WikiDiscussions master Synced 1mo ago

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

UnionPay - 银联支付
===============

[](#unionpay---银联支付)

[![Latest Stable Version](https://camo.githubusercontent.com/a26eb972fec5a8e41afac8a75bd5a83e4ce088fd0b1c8fcdfc4b9e72a9dad5f1/68747470733a2f2f706f7365722e707567782e6f72672f7a68616e67762f756e696f6e2d7061792f762f737461626c65)](https://packagist.org/packages/zhangv/union-pay)[![License](https://camo.githubusercontent.com/f94028dd58babd26c6469aeaeaf01d555ff931832e1651cc93ceac777c066537/68747470733a2f2f706f7365722e707567782e6f72672f7a68616e67762f756e696f6e2d7061792f6c6963656e7365)](https://packagist.org/packages/zhangv/union-pay)[![Build Status](https://camo.githubusercontent.com/695a37c0de418ad55487b34ad40baef761d6aca092ed6d98733b55717eebca5a/68747470733a2f2f7472617669732d63692e6f72672f7a68616e67762f756e696f6e2d7061792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/zhangv/union-pay)[![codecov](https://camo.githubusercontent.com/5da002ef9aa84e3e6b88f8b80b156458be2015eb093e599e12150f31318b7616/68747470733a2f2f636f6465636f762e696f2f67682f7a68616e67762f756e696f6e2d7061792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/zhangv/union-pay)

simplest union pay - no dependency to any library, simple enough to let you hack.

### Feature

[](#feature)

- [B2C - 在线网关支付](src/service/B2C.php)
- [Wap - 手机网页支付（WAP支付）](src/service/Wap.php)
- [App - App/控件支付](src/service/App.php)
- [B2B - 企业网银支付](src/service/B2B.php)
- [Direct - 无跳转标准版](src/service/Direct.php)
- [Token - 无跳转Token版](src/service/Token.php)
- [Qrcode - 二维码支付](src/service/Qrcode.php)
- [DirectDebit - 代收](src/service/DirectDebit.php)
- [Charge - 便民缴费产品](src/service/Charge.php)
- 刷脸支付 （TODO）
- 跨境电商海关申报（TODO）

### Install

[](#install)

```
composer require zhangv/union-pay

```

or

add:

```
"zhangv/union-pay":"0.8.12"

```

in composer.json

### Step 1: [config.php](demo/config.php) - 配置

[](#step-1-configphp---配置)

```
return ['test', [
		'version' => '5.1.0',
		'signMethod'=> '01', //RSA
		'encoding' => 'UTF-8',
		'merId' => '700000000000001',
		'returnUrl' => 'http://dev.git.com/union-pay/demo/payreturn.php', //前台网关支付返回
		'notifyUrl' => 'http://dev.git.com/union-pay/demo/paynotify.php', //后台通知
		'frontFailUrl'   => 'http://dev.git.com/union-pay/demo/payfail.php',
		'refundnotifyUrl' => 'http://dev.git.com.com/union-pay/demo/refundnotify.php',
		'signCertPath' => dirname(__FILE__).'/../cert/acp_test_sign.pfx',
		'signCertPwd' => '000000', //签名证书密码
		'verifyCertPath' => dirname(__FILE__).'/../cert/acp_test_verify_sign.cer',  //v5.0.0 required
		'verifyRootCertPath' => dirname(__FILE__).'/../cert/acp_test_root.cer', //v5.1.0 required
		'verifyMiddleCertPath' => dirname(__FILE__).'/../cert/acp_test_middle.cer', //v5.1.0 required
		'encryptCertPath' => dirname(__FILE__).'/../cert/acp_test_enc.cer',
		'ifValidateCNName' => false, //正式环境设置为true
	]
];
```

### Step 2: [pay.php](demo/b2c/pay.php) - 支付

[](#step-2-payphp---支付)

```
