浏览代码

微信二维码预支付

whitefang 1 年之前
父节点
当前提交
952a6b556e
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      app/api/controller/PayController.php

+ 22 - 0
app/api/controller/PayController.php

@@ -69,6 +69,28 @@ class PayController extends BaseApiController
         return $this->success('', $result);
     }
 
+    /**
+     * 微信二维码预支付
+     * @return \think\response\Json
+     */
+    public function preNativePay()
+    {
+        $params = (new PayValidate())->post()->goCheck();
+        //订单信息
+        $order = PaymentLogic::getPayOrderInfo($params);
+        if (false === $order) {
+            return $this->fail(PaymentLogic::getError(), $params);
+        }
+        //支付流程
+        $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
+        $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, 4, $redirectUrl);
+        if (false === $result) {
+            return $this->fail(PaymentLogic::getError(), $params);
+        }
+        $result['sn'] = $order['sn'];
+        return $this->success('', $result);
+    }
+
 
     /**
      * @notes 获取支付状态