panda 1 年之前
父节点
当前提交
2db80d057c
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 13 4
      application/api/controller/Passport.php

+ 13 - 4
application/api/controller/Passport.php

@@ -112,10 +112,19 @@ class Passport extends Api
 
         $pay = new PayUtil();
         $order_no = !empty($order_no) ? $order_no : time() . rand(1, 200);
-        $pay->jsPay($openid, "D0{$order_no}", '0.01', '开通会员');
-        return json_encode([
-            'order_no' => $order_no,
-            'data' => $pay->getData()
+        $res = $pay->jsPay($openid, "D0{$order_no}", '0.01', '开通会员');
+        if (empty($res['data']['bank_code']) || $res['data']['bank_code'] != 'SUCCESS'){
+            $this->error($res['data']['bank_message'] ?? '下单失败');
+        }
+
+        if (empty($res['data']['pay_info']) || !$pay_info = json_decode($res['data']['pay_info'],true)){
+            $this->error('支付信息有误');
+            return;
+        }
+
+        $this->success('success', [
+            'pay_info' => $pay_info,
+            'order_no' => $order_no
         ]);
     }
 }