xplwechat / weixin
yii2微信支付组件
v0.1
2018-04-01 07:08 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-29 05:41:54 UTC
README
yii2微信支付组件
安装
安装此扩展的首选方式是通过 composer。
可以运行
php composer.phar require xplwechat/weixin
或者在您的 composer.json 的 require
部分添加
"xplwechat/weixin": "*"
到
配置
要使用此扩展,只需在您的应用程序配置中添加以下代码
return [ //.... 'components' => [ 'wxpay'=>[ 'class'=>'xplwechat\weixin\Wxpay', 'back_url'=> '回调地址', 'app_id'=>'APPID', 'mch_id'=>'MCHID', 'key'=>'KEY', 'app_secret'=>'APPSECRET', 'ssl_cert_path'=>'../cert/apiclient_cert.pem', 'ssl_key_path'=>'../cert/apiclient_key.pem', 'curl_proxy_host'=>'0.0.0.0', 'curl_proxy_port'=>0, 'report_level'=>1, ], ], ]; [生成支付信息] $result = \Yii::$app->wxpay->unifiedOrder([ 'attach'=>'扩展字段', 'out_trade_no'=>'订单号', 'price'=>'价格(分)', 'body'=>'商品描述', 'tag'=>'商品标签', 'id'=>'商品ID', ]) 将result通过json形式返给客户端即可 [回调代码] -------------------- $result = false; if($notifyData = \Yii::$app->wxpay->notify()){ $result = "回调逻辑"; } if($result){ echo '<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>'; }else{ echo '<xml><return_code><![CDATA[FAIL]]></return_code></xml>'; }