panda 1 year ago
parent
commit
73c4cd701b
2 changed files with 5 additions and 4 deletions
  1. 1 1
      application/index/controller/Index.php
  2. 4 3
      application/utils/PayUtil.php

+ 1 - 1
application/index/controller/Index.php

@@ -20,7 +20,7 @@ class Index extends Frontend
     {
         $pay = new PayUtil();
         $order_no = time().rand(1,200);
-        $pay->jsPay("D0{$order_no}",'0.01','开通会员');
+        $pay->jsPay('',"D0{$order_no}",'0.01','开通会员');
         return json_encode([
             'order_no' => $order_no,
             'data' => $pay->getData()

+ 4 - 3
application/utils/PayUtil.php

@@ -12,6 +12,7 @@ class PayUtil
     public function __construct()
     {
         $this->config = [
+            'sub_appid' => 'wx29d6281c5252f504',
             'huifu_id' => '6666000145960408',
             'sys_id' => '6666000145960408',
             'product_id' => 'YMFZS',
@@ -19,7 +20,7 @@ class PayUtil
         ];
     }
 
-    public function jsPay(string $order_no, string $amount, string $desc = '', string $notify_url = '', string $type = 'T_MINIAPP')
+    public function jsPay(string $openid,string $order_no, string $amount, string $desc = '', string $notify_url = '', string $type = 'T_MINIAPP')
     {
         $url = "https://api.huifu.com/v2/trade/payment/jspay";
 
@@ -33,8 +34,8 @@ class PayUtil
             'trade_type' => $type,
             'trans_amt' => $amount,// 交易金额 单位元 最低传入0.01
             'wx_data' => [
-                'sub_appid' => 'wx29d6281c5252f504',
-                'sub_openid' => '123',
+                'sub_appid' => $this->config['sub_appid'],
+                'sub_openid' => $openid,
             ],
             'notify_url' => ''
         ];