php-cpm/omnipay-unionpay
Composer 安装命令:
composer require php-cpm/omnipay-unionpay
包简介
UnionPay gateway for Omnipay payment processing library
README 文档
README
UnionPay driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements UnionPay support for Omnipay.
Installation
Omnipay is installed via Composer. To install, simply add it
to your composer.json file:
{
"require": {
"lokielse/omnipay-unionpay": "^0.4"
}
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
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
Sandbox Param can be found at: UnionPay Developer Center
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
$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
$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
$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.
Related
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.
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.
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.
php-cpm/omnipay-unionpay 适用场景与选型建议
php-cpm/omnipay-unionpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 338 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「pay」 「gateway」 「merchant」 「purchase」 「omnipay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 php-cpm/omnipay-unionpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-cpm/omnipay-unionpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 php-cpm/omnipay-unionpay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Библиотека для приема платежей через Альфабанк.
Some pre-defined rules for validation in Omnipay payment processing library.
BluePay gateway for the Omnipay payment processing library
支付宝接口扩展包
统计信息
- 总下载量: 338
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-05