订单支付微信环境中支付逻辑优化

This commit is contained in:
Devil 2020-01-02 00:25:03 +08:00
parent cf3bec796b
commit 72da6fe48a

View File

@ -143,7 +143,7 @@ class OrderService
}
}
// 发起支付
// 发起支付数据
$pay_data = array(
'user' => $params['user'],
'out_user' => md5($params['user']['id']),
@ -173,6 +173,17 @@ class OrderService
return $ret;
}
// 微信中打开并且webopenid为空
if(in_array(APPLICATION_CLIENT_TYPE, ['pc', 'h5']))
{
if(!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false && empty($pay_data['user']['weixin_web_openid']))
{
// 授权成功后回调订单详情页面重新自动发起支付
$url = MyUrl('index/order/detail', ['id'=>$pay_data['order_id'], 'is_pay_auto'=>1, 'is_pay_submit'=>1]);
session('plugins_weixinwebauth_pay_callback_view_url', $url);
}
}
// 发起支付
$pay_name = 'payment\\'.$payment[0]['payment'];
$ret = (new $pay_name($payment[0]['config']))->Pay($pay_data);