From c808eb2249d9f61884a38d04796a55e8e281cc92 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 20 Oct 2020 16:05:35 +0800 Subject: [PATCH] 1 --- webapp/sdkwarpper/UnifiedWeiXin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/sdkwarpper/UnifiedWeiXin.php b/webapp/sdkwarpper/UnifiedWeiXin.php index 5826d69..5e75ae8 100644 --- a/webapp/sdkwarpper/UnifiedWeiXin.php +++ b/webapp/sdkwarpper/UnifiedWeiXin.php @@ -35,7 +35,7 @@ class UnifiedWeiXin extends BaseSdk { public function preOrder() { - if (!($_REQUEST['unified_trade_type'])) { + if (!($_REQUEST['unified_trade_type'] == 'MWEB' || $_REQUEST['unified_trade_type'] == 'JSAPI')) { phpcommon\sendError(1, '参数错误,unified_trade_type必须为MWEB或JSAPI'); return; } @@ -60,6 +60,7 @@ class UnifiedWeiXin extends BaseSdk { ); } + $openid = phpcommon\extractOpenId($_REQUEST['account_id']); $params = array( 'appid' => $this->conf_appid, 'mch_id' => $this->conf_mch_id, @@ -72,6 +73,9 @@ class UnifiedWeiXin extends BaseSdk { 'trade_type' => $_REQUEST['unified_trade_type'], //'scene_info' => '', ); + if ($_REQUEST['unified_trade_type'] == 'JSAPI') { + $params['openid'] = $openid; + } if (SERVER_ENV != _ONLINE) { $params['notify_url'] = 'https://gamepay-test.kingsome.cn/webapp/paynotify/unified_weixin.php'; } @@ -90,7 +94,7 @@ class UnifiedWeiXin extends BaseSdk { phpcommon\sendError(1, '服务器内部错误'); return; } - echo $response; + error_log($response); $xml = new \SimpleXMLElement($response); if ($xml->return_code != 'SUCCESS') { phpcommon\sendError(2, $xml->return_msg);