From 4eba7c0905c5efa1263ef056b1e8d8631b0d5720 Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 4 May 2018 18:11:49 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=89=AB=E7=A0=81=E6=94=AF=E4=BB=982?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/store/controller/wechat/Demo.php | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/application/store/controller/wechat/Demo.php b/application/store/controller/wechat/Demo.php index 323ad45cb..e7139b2b1 100644 --- a/application/store/controller/wechat/Demo.php +++ b/application/store/controller/wechat/Demo.php @@ -40,9 +40,43 @@ class Demo return $this->createQrc($result); } + /** + * 通过处理 + * @return string + * @throws \WeChat\Exceptions\InvalidResponseException + */ public function scanOneNotify() { - p(file_get_contents('php://input')); + $notify = \WeChat\Tools::xml2arr(file_get_contents('php://input')); + p('======= 来自扫码支付1的数据 ======'); + p($notify); + // 微信统一下单处理 + $options = [ + 'body' => '测试商品', + 'out_trade_no' => time(), + 'total_fee' => '1', + 'trade_type' => 'NATIVE', + 'notify_url' => url('@wx-demo-notify', '', true, true), + 'spbill_create_ip' => request()->ip(), + ]; + $wechat = new Pay(config('wechat.')); + $order = $wechat->createOrder($options); + p('======= 来自扫码支付1统一下单结果 ======'); + p($order); + // 回复XML文本 + $result = [ + 'return_code' => 'SUCCESS', + 'return_msg' => '处理成功', + 'appid' => $notify['appid'], + 'mch_id' => $notify['mch_id'], + 'nonce_str' => \WeChat\Tools::createNoncestr(), + 'prepay_id' => $order['prepay_id'], + 'result_code' => 'SUCCESS', + ]; + $result['sign'] = $wechat->getPaySign($result); + p('======= 来自扫码支付1返回的结果 ======'); + p($result); + return \WeChat\Tools::arr2xml($result); } /**