Authored by 郝肖肖

weixin openid cookile

@@ -122,7 +122,7 @@ class JsApiPay @@ -122,7 +122,7 @@ class JsApiPay
122 //取出openid 122 //取出openid
123 $data = json_decode($res, true); 123 $data = json_decode($res, true);
124 //初始化 124 //初始化
125 - if (empty($data)) { 125 + if (empty($data) || empty($data['openid'])) {
126 $data['access_token'] = false; 126 $data['access_token'] = false;
127 $data['openid'] = false; 127 $data['openid'] = false;
128 } 128 }
@@ -982,12 +982,12 @@ class HomeController extends AbstractAction @@ -982,12 +982,12 @@ class HomeController extends AbstractAction
982 982
983 $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false; 983 $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
984 if ($hasWxShare) { 984 if ($hasWxShare) {
985 - $openId = $this->getCookie('weixinOpenId' . $orderCode); 985 + $openId = $this->getSession('weixinOpenId' . $orderCode);
986 if (empty($openId)) { 986 if (empty($openId)) {
987 $tools = new JsApiPay(); 987 $tools = new JsApiPay();
988 $openId = $tools->GetOpenid(); 988 $openId = $tools->GetOpenid();
989 if ($openId) { 989 if ($openId) {
990 - $this->setCookie('weixinOpenId' . $orderCode, $openId, 600); 990 + $this->setSession('weixinOpenId' . $orderCode, $openId);
991 } 991 }
992 } 992 }
993 } 993 }
@@ -1050,7 +1050,7 @@ class HomeController extends AbstractAction @@ -1050,7 +1050,7 @@ class HomeController extends AbstractAction
1050 } 1050 }
1051 1051
1052 $totalFee = strval($orderDetail['data']['payment_amount'] * 100); 1052 $totalFee = strval($orderDetail['data']['payment_amount'] * 100);
1053 - $openId = $this->getCookie('weixinOpenId' . $orderCode); 1053 + $openId = $this->getSession('weixinOpenId' . $orderCode);
1054 if (empty($openId)) { 1054 if (empty($openId)) {
1055 UdpLog::info('【微信支付下单】Session中的weixinOpenId校验','weixinOpenId为空'); 1055 UdpLog::info('【微信支付下单】Session中的weixinOpenId校验','weixinOpenId为空');
1056 break; 1056 break;
@@ -121,7 +121,7 @@ class PayController extends AbstractAction @@ -121,7 +121,7 @@ class PayController extends AbstractAction
121 } 121 }
122 122
123 $totalFee = strval($orderDetail['data']['payment_amount'] * 100); 123 $totalFee = strval($orderDetail['data']['payment_amount'] * 100);
124 - $openId = $this->getCookie('weixinOpenId' . $orderCode); 124 + $openId = $this->getSession('weixinOpenId' . $orderCode);
125 if (empty($openId)) { 125 if (empty($openId)) {
126 UdpLog::info('【wechat支付】获取wechat标识为空', 'orderCode:'.$orderCode.'uid:'.$uid.'返回openId:'.$openId); 126 UdpLog::info('【wechat支付】获取wechat标识为空', 'orderCode:'.$orderCode.'uid:'.$uid.'返回openId:'.$openId);
127 break; 127 break;