{"id":15029019,"url":"https://github.com/codeages/omnipay-wechatpay","last_synced_at":"2025-10-03T23:33:13.316Z","repository":{"id":56954839,"uuid":"184212245","full_name":"codeages/omnipay-wechatpay","owner":"codeages","description":"（微信支付）WechatPay driver for the Omnipay PHP payment processing library PHP 5.3+","archived":false,"fork":true,"pushed_at":"2019-05-09T03:17:30.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-29T21:53:03.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"canuonifeng/omnipay-wechatpay","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeages.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":"2019-04-30T07:20:49.000Z","updated_at":"2019-05-09T03:14:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/codeages/omnipay-wechatpay","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeages%2Fomnipay-wechatpay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeages%2Fomnipay-wechatpay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeages%2Fomnipay-wechatpay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeages%2Fomnipay-wechatpay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeages","download_url":"https://codeload.github.com/codeages/omnipay-wechatpay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235204448,"owners_count":18952326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-24T20:09:33.702Z","updated_at":"2025-10-03T23:33:07.987Z","avatar_url":"https://github.com/codeages.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Omnipay: WechatPay\n\n* forked from [lokielse/omnipay-wechatpay](https://github.com/lokielse/omnipay-wechatpay)\n* for PHP 5.3+\n* add refunded notify\n\n## Installation\n\nOmnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it\nto your `composer.json` file:\n\n    \"codeages/omnipay-wechatpay\": \"^1.0\",\n\nAnd run composer to update your dependencies:\n\n    $ composer update -vvv\n\n## Basic Usage\n\nThe following gateways are provided by this package:\n\n\n* WechatPay (Wechat Common Gateway) 微信支付通用网关\n* WechatPay_App (Wechat App Gateway) 微信APP支付网关\n* WechatPay_Native (Wechat Native Gateway) 微信原生扫码支付支付网关\n* WechatPay_Js (Wechat Js API/MP Gateway) 微信网页、公众号、小程序支付网关\n* WechatPay_Pos (Wechat Micro/POS Gateway) 微信刷卡支付网关\n* WechatPay_Mweb (Wechat H5 Gateway) 微信H5支付网关\n\n## Usage\n\n### Create Order [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1)\n\n```php\n//gateways: WechatPay_App, WechatPay_Native, WechatPay_Js, WechatPay_Pos, WechatPay_Mweb\n$gateway    = Omnipay::create('WechatPay_App');\n$gateway-\u003esetAppId($config['app_id']);\n$gateway-\u003esetMchId($config['mch_id']);\n$gateway-\u003esetApiKey($config['api_key']);\n\n$order = [\n    'body'              =\u003e 'The test order',\n    'out_trade_no'      =\u003e date('YmdHis').mt_rand(1000, 9999),\n    'total_fee'         =\u003e 1, //=0.01\n    'spbill_create_ip'  =\u003e 'ip_address',\n    'fee_type'          =\u003e 'CNY'\n];\n\n/**\n * @var Omnipay\\WechatPay\\Message\\CreateOrderRequest $request\n * @var Omnipay\\WechatPay\\Message\\CreateOrderResponse $response\n */\n$request  = $gateway-\u003epurchase($order);\n$response = $request-\u003esend();\n\n//available methods\n$response-\u003eisSuccessful();\n$response-\u003egetData(); //For debug\n$response-\u003egetAppOrderData(); //For WechatPay_App\n$response-\u003egetJsOrderData(); //For WechatPay_Js\n$response-\u003egetCodeUrl(); //For Native Trade Type\n```\n\n### Notify [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_7\u0026index=3)\n```php\n$gateway    = Omnipay::create('WechatPay');\n$gateway-\u003esetAppId($config['app_id']);\n$gateway-\u003esetMchId($config['mch_id']);\n$gateway-\u003esetApiKey($config['api_key']);\n\n$response = $gateway-\u003ecompletePurchase([\n    'request_params' =\u003e file_get_contents('php://input')\n])-\u003esend();\n\nif ($response-\u003eisPaid()) {\n    //pay success\n    var_dump($response-\u003egetRequestData());\n}else{\n    //pay fail\n}\n```\n\n### Query Order [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1)\n```php\n$response = $gateway-\u003equery([\n    'transaction_id' =\u003e '1217752501201407033233368018', //The wechat trade no\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n\n### Close Order [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_3\u0026index=5)\n```php\n$response = $gateway-\u003eclose([\n    'out_trade_no' =\u003e '201602011315231245', //The merchant trade no\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n### Refund [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_4\u0026index=6)\n```php\n$gateway-\u003esetCertPath($certPath);\n$gateway-\u003esetKeyPath($keyPath);\n\n$response = $gateway-\u003erefund([\n    'transaction_id' =\u003e '1217752501201407033233368018', //The wechat trade no\n    'out_refund_no' =\u003e $outRefundNo,\n    'total_fee' =\u003e 1, //=0.01\n    'refund_fee' =\u003e 1, //=0.01\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n### Refund Notify [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_16\u0026index=10)\n```php\n$gateway    = Omnipay::create('WechatPay');\n$gateway-\u003esetAppId($config['app_id']);\n$gateway-\u003esetMchId($config['mch_id']);\n$gateway-\u003esetApiKey($config['api_key']);\n\n$response = $gateway-\u003ecompleteRefund([\n    'request_params' =\u003e file_get_contents('php://input')\n])-\u003esend();\n\nif ($response-\u003eisRefunded()) {\n    //pay success\n    var_dump($response-\u003egetRequestData());\n}else{\n    //pay fail\n}\n```\n\n### QueryRefund [doc](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_5\u0026index=7)\n```php\n$response = $gateway-\u003equeryRefund([\n    'refund_id' =\u003e '1217752501201407033233368018', //Your site trade no, not union tn.\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\n```\n\n### Shorten URL (for `WechatPay_Native`) [doc](https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_9\u0026index=8)\n```php\n$response = $gateway-\u003eshortenUrl([\n    'long_url' =\u003e $longUrl\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\nvar_dump($response-\u003egetShortUrl());\n```\n\n### Query OpenId (for `WechatPay_Pos`) [doc](https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13\u0026index=9)\n```php\n$response = $gateway-\u003eshortenUrl([\n    'auth_code' =\u003e $authCode\n])-\u003esend();\n\nvar_dump($response-\u003eisSuccessful());\nvar_dump($response-\u003egetData());\nvar_dump($response-\u003egetOpenId());\n```\n\nFor general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)\nrepository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeages%2Fomnipay-wechatpay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeages%2Fomnipay-wechatpay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeages%2Fomnipay-wechatpay/lists"}