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

+ 22 - 0
application/api/controller/Passport.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use app\utils\Easywechat\MiniAppService;
+use app\utils\PayUtil;
 use think\Cache;
 
 /**
@@ -96,4 +97,25 @@ class Passport extends Api
             'openid' => $sign
         ]);
     }
+
+    /**
+     * 测试 汇付 支付
+     */
+    public function testPay()
+    {
+        $params = \request()->post();
+        $order_no = $params['order_no'] ?? '';
+
+        $wxInfo = Cache::get($params['openid'] ?? '');
+        $openid = $wxInfo['openid'] ?? '';
+//        $sessionKey = $wxInfo['session_key'] ?? '';
+
+        $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()
+        ]);
+    }
 }