Sfoglia il codice sorgente

支付加平台参数

gorden 8 mesi fa
parent
commit
308db01819
1 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 9 1
      app/api/controller/pay/WxpayController.php

+ 9 - 1
app/api/controller/pay/WxpayController.php

@@ -41,8 +41,16 @@ class WxpayController
             if ($params['platform'] == 'android'){
                 $wxpay = Pay::wechat(config('payment.wxpay'))->app($payData)->getContent();
             }elseif ($params['platform'] == 'WeChat'){
-                $wxpay = Pay::wechat(config('payment.wxpay'))->wap($payData)->getContent();
+                if (!empty($params['openid'])){
+                    throw new PayException("缺少OpenID 参数");
+                }
+                $payData['openid'] = $params['openid'];
+                $wxpay = Pay::wechat(config('payment.wxpay'))->mp($payData)->getContent();
             }elseif ($params['platform'] == 'mp-weixin'){
+                if (!empty($params['openid'])){
+                    throw new PayException("缺少OpenID 参数");
+                }
+                $payData['openid'] = $params['openid'];
                 $wxpay = Pay::wechat(config('payment.wxpay'))->miniapp($payData)->getContent();
             }else{
                 throw new PayException("平台参数无效");