panda 1 年之前
父節點
當前提交
a6bb0cb840
共有 2 個文件被更改,包括 55 次插入1 次删除
  1. 54 0
      application/api/controller/Passport.php
  2. 1 1
      application/utils/PayUtil.php

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

@@ -130,4 +130,58 @@ class Passport extends Api
             'order_no' => $order_no
             'order_no' => $order_no
         ]);
         ]);
     }
     }
+
+    /**
+     * 支付回调
+     * @return void
+     */
+    public function pay_notify()
+    {
+//        $params = \request()->post();
+//
+//        $params = json_encode($params,JSON_UNESCAPED_UNICODE);
+
+        $this->notify_log_start('hf_pay');
+    }
+
+    //异步日志
+    private function notify_log_start($paytype = 'wechat')
+    {
+        //记录支付回调数据
+        ignore_user_abort(); // run script in background
+        set_time_limit(30);
+        // 日志文件 start
+        $log_base_dir = '../paylog/' . $paytype . '/';
+        if (!is_dir($log_base_dir)) {
+            mkdir($log_base_dir, 0770, true);
+            @chmod($log_base_dir, 0770);
+        }
+        $notify_file = $log_base_dir . 'notify.txt';
+        if (!file_exists($notify_file)) {
+            @touch($notify_file);
+            @chmod($notify_file, 0770);
+        }
+        if (filesize($notify_file) > 5242880)//大于5M自动切换
+        {
+            rename($notify_file, $log_base_dir . 'notify_' . date('Y_m_d_H_i_s') . '.txt');
+        }
+        if (!file_exists($notify_file)) {
+            @touch($notify_file);
+            @chmod($notify_file, 0770);
+        }
+        // 日志文件 end
+        //开始写入
+        $_REQUEST = isset($_REQUEST) ? $_REQUEST : array();
+        if ($_REQUEST && $paytype == 'alipay') {
+            file_put_contents($notify_file, "\r\n\r\n" . date('Y-m-d H:i:s') . " [notify][入口接收request]" . json_encode($_REQUEST), FILE_APPEND);
+        } else {
+            $xml = file_get_contents("php://input");
+            file_put_contents($notify_file, "\r\n\r\n" . date('Y-m-d H:i:s') . " [notify][入口接收php://input流原始数据] \n" . $xml, FILE_APPEND);
+            $xmlObj = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
+            file_put_contents($notify_file, "\r\n\r\n" . date('Y-m-d H:i:s') . " [notify][入口接收php://input流] " . json_encode($xmlObj), FILE_APPEND);
+        }
+
+        ini_set('display_errors', 'On');
+        return $notify_file;
+    }
 }
 }

+ 1 - 1
application/utils/PayUtil.php

@@ -21,7 +21,7 @@ class PayUtil
 
 
     public function jsPay(string $openid, 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";
+        $url = "http://www.zhiyinvip001.com/api/passport/pay_notify";
 
 
         $post_data = [
         $post_data = [
             'req_date' => date('Ymd'),
             'req_date' => date('Ymd'),