{"id":33217147,"url":"https://github.com/lokielse/omnipay-unionpay","last_synced_at":"2026-04-04T12:58:06.623Z","repository":{"id":36448388,"uuid":"40753440","full_name":"lokielse/omnipay-unionpay","owner":"lokielse","description":"UnionPay driver for the Omnipay PHP payment processing library","archived":false,"fork":false,"pushed_at":"2020-08-19T09:13:56.000Z","size":117,"stargazers_count":113,"open_issues_count":11,"forks_count":46,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-12-17T10:44:26.702Z","etag":null,"topics":["omnipay","payment","unionpay"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lokielse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-15T09:28:39.000Z","updated_at":"2025-11-10T06:02:03.000Z","dependencies_parsed_at":"2022-08-18T14:21:58.269Z","dependency_job_id":null,"html_url":"https://github.com/lokielse/omnipay-unionpay","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/lokielse/omnipay-unionpay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokielse%2Fomnipay-unionpay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokielse%2Fomnipay-unionpay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokielse%2Fomnipay-unionpay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokielse%2Fomnipay-unionpay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lokielse","download_url":"https://codeload.github.com/lokielse/omnipay-unionpay/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokielse%2Fomnipay-unionpay/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31400460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["omnipay","payment","unionpay"],"created_at":"2025-11-16T14:00:18.919Z","updated_at":"2026-04-04T12:58:06.617Z","avatar_url":"https://github.com/lokielse.png","language":"PHP","funding_links":[],"categories":["电子商务( E-commerce )"],"sub_categories":[],"readme":"# Omnipay: UnionPay\n\n[![Build Status](https://travis-ci.org/lokielse/omnipay-unionpay.png?branch=master)](https://travis-ci.org/lokielse/omnipay-unionpay)\n[![Latest Stable Version](https://poser.pugx.org/lokielse/omnipay-unionpay/version.png)](https://packagist.org/packages/lokielse/omnipay-unionpay)\n[![Total Downloads](https://poser.pugx.org/lokielse/omnipay-unionpay/d/total.png)](https://packagist.org/packages/lokielse/omnipay-unionpay)\n\n**UnionPay driver for the Omnipay PHP payment processing library**\n\n\n[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment\nprocessing library for PHP 7.1+. This package implements UnionPay support for Omnipay.\n\n## Installation\n\nOmnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it\nto your `composer.json` file:\n\n```json\n{\n    \"require\": {\n        \"lokielse/omnipay-unionpay\": \"^0.4\"\n    }\n}\n```\n\nAnd run composer to update your dependencies:\n\n    $ curl -s http://getcomposer.org/installer | php\n    $ php composer.phar update\n\n## Basic Usage\n\nThe following gateways are provided by this package:\n\n* Union_Wtz (Union No Redirect Payment) 银联无跳转支付（alpha）\n* Union_Express (Union Express Payment) 银联全产品网关（PC，APP，WAP支付）\n* Union_LegacyMobile (Union Legacy Mobile Payment) 银联老网关（APP）\n* Union_LegacyQuickPay (Union Legacy QuickPay Payment) 银联老网关（PC）\n\n## Usage\n\nSandbox Param can be found at: [UnionPay Developer Center](https://open.unionpay.com/ajweb/account/testPara)\n\n## Prepare\n\nHow to get `PrivateKey`, `PublicKey`, `Cert ID`:\n\n```\n0. Prepare cert.pfx and its password, verify_sign_acp.cer\n\n1. Get Private Key\n$ openssl pkcs12 -in cert.pfx  -nocerts -nodes | openssl rsa -out private_key.pem\n\n2. Public key is verify_sign_acp.cer\n\n3. Get Cert ID\n$ openssl pkcs12 -in cert.pfx -clcerts -nokeys | openssl x509 -serial -noout // result hex eg: XXXXXXXXXX\n$ visit https://lokielse.github.io/hex2dec //Convert hex to decimal online\n```\n\n### Consume\n\n```php\n$gateway    = Omnipay::create('UnionPay_Express');\n$gateway-\u003esetMerId($config['merId']);\n$gateway-\u003esetCertId($config['certId']);\n$gateway-\u003esetPrivateKey($config['privateKey']); // path or content\n$gateway-\u003esetReturnUrl($config['returnUrl']);\n$gateway-\u003esetNotifyUrl($config['notifyUrl']);\n\n$order = [\n    'orderId'   =\u003e date('YmdHis'), //Your order ID\n    'txnTime'   =\u003e date('YmdHis'), //Should be format 'YmdHis'\n    'orderDesc' =\u003e 'My order title', //Order Title\n    'txnAmt'    =\u003e '100', //Order Total Fee\n];\n\n//For PC/Wap\n$response = $gateway-\u003epurchase($order)-\u003esend();\n$response-\u003egetRedirectHtml();\n\n//For APP\n$response = $gateway-\u003ecreateOrder($order)-\u003esend();\n$response-\u003egetTradeNo();\n\n```\n\n### Return/Notify\n```php\n$gateway    = Omnipay::create('UnionPay_Express');\n$gateway-\u003esetMerId($config['merId']);\n$gateway-\u003esetPublicKey($config['publicKey']); // path or content\n\n$response = $gateway-\u003ecompletePurchase(['request_params'=\u003e$_REQUEST])-\u003esend();\n\nif ($response-\u003eisPaid()) {\n    //pay success\n}else{\n    //pay fail\n}\n```\n\n### Query Order Status\n```php\n$response = $gateway-\u003equery([\n    'orderId' =\u003e '20150815121214', //Your site trade no, not union tn.\n    'txnTime' =\u003e '20150815121214', //Order trade time\n    'txnAmt'  =\u003e '200', //Order total fee\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n### Consume Undo\n```php\n$response = $gateway-\u003econsumeUndo([\n    'orderId' =\u003e '20150815121214', //Your site trade no, not union tn.\n    'txnTime' =\u003e date('YmdHis'), //Regenerate a new time\n    'txnAmt'  =\u003e '200', //Order total fee\n    'queryId' =\u003e 'xxxxxxxxx', //Order total fee\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n### Refund\n```php\n// 注意：\n1. 银联退款时，必须加上 queryId, \n2. 作为商户生成的订单号orderId与退款时的订单号是不一样的。也就意味着退款时的订单号必须重新生成。\n3. txnAmt 这个参数银联是精确到分的。直接返回元为单位的值，将会出现报错信息。\n// get the queryId first\n$response = $gateway-\u003equery([\n    'orderId' =\u003e '20150815121214', //Your site trade no, not union tn.\n    'txnTime' =\u003e '20150815121214', //Order trade time\n    'txnAmt'  =\u003e 200 * 100, //Order total fee; notice that: you should multiply the txnAmt by 100 with the Unionpay gateway. Such as 200 * 100;\n])-\u003esend();\n$queryId = ($response-\u003egetData())['queryId'];\n$response = $gateway-\u003erefund([\n    'orderId' =\u003e '20150815121214', //Your site trade no, not union tn. notice: this orderId must not be the same with the order's created orderId.\n    'txnTime' =\u003e date('YmdHis'), //Order trade time\n    'txnAmt'  =\u003e 200 * 100, //Order total fee; notice that: you should multiply the txnAmt by 100 with the Unionpay gateway. Such as 200 * 100;\n    'queryId' =\u003e $queryId\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n### File Transfer\n```php\n$response = $gateway-\u003efileTransfer([\n    'txnTime'    =\u003e '20150815121214', //Order trade time\n    'settleDate' =\u003e '0119', //Settle Date\n    'fileType'   =\u003e '00', //File Type\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n\nFor general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)\nrepository.\n\n## Related\n\n- [Laravel-Omnipay](https://github.com/ignited/laravel-omnipay)\n- [Omnipay-Alipay](https://github.com/lokielse/omnipay-alipay)\n- [Omnipay-WechatPay](https://github.com/lokielse/omnipay-wechatpay)\n\n## Support\n\nIf you are having general issues with Omnipay, we suggest posting on\n[Stack Overflow](http://stackoverflow.com/). Be sure to add the\n[omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.\n\nIf you want to keep up to date with release anouncements, discuss ideas for the project,\nor ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which\nyou can subscribe to.\n\nIf you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/lokielse/omnipay-unionpay/issues),\nor better yet, fork the library and submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flokielse%2Fomnipay-unionpay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flokielse%2Fomnipay-unionpay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flokielse%2Fomnipay-unionpay/lists"}