This commit is contained in:
aozhiwei 2020-10-20 16:05:35 +08:00
parent 8f6fb4adf7
commit c808eb2249

View File

@ -35,7 +35,7 @@ class UnifiedWeiXin extends BaseSdk {
public function preOrder() 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'); phpcommon\sendError(1, '参数错误,unified_trade_type必须为MWEB或JSAPI');
return; return;
} }
@ -60,6 +60,7 @@ class UnifiedWeiXin extends BaseSdk {
); );
} }
$openid = phpcommon\extractOpenId($_REQUEST['account_id']);
$params = array( $params = array(
'appid' => $this->conf_appid, 'appid' => $this->conf_appid,
'mch_id' => $this->conf_mch_id, 'mch_id' => $this->conf_mch_id,
@ -72,6 +73,9 @@ class UnifiedWeiXin extends BaseSdk {
'trade_type' => $_REQUEST['unified_trade_type'], 'trade_type' => $_REQUEST['unified_trade_type'],
//'scene_info' => '', //'scene_info' => '',
); );
if ($_REQUEST['unified_trade_type'] == 'JSAPI') {
$params['openid'] = $openid;
}
if (SERVER_ENV != _ONLINE) { if (SERVER_ENV != _ONLINE) {
$params['notify_url'] = 'https://gamepay-test.kingsome.cn/webapp/paynotify/unified_weixin.php'; $params['notify_url'] = 'https://gamepay-test.kingsome.cn/webapp/paynotify/unified_weixin.php';
} }
@ -90,7 +94,7 @@ class UnifiedWeiXin extends BaseSdk {
phpcommon\sendError(1, '服务器内部错误'); phpcommon\sendError(1, '服务器内部错误');
return; return;
} }
echo $response; error_log($response);
$xml = new \SimpleXMLElement($response); $xml = new \SimpleXMLElement($response);
if ($xml->return_code != 'SUCCESS') { if ($xml->return_code != 'SUCCESS') {
phpcommon\sendError(2, $xml->return_msg); phpcommon\sendError(2, $xml->return_msg);