From f26738ec085f602a4a334552e3873573c3c012a0 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sun, 8 Jan 2023 19:47:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Library/Org/Kudian/Client.php | 4 ++++ ThinkPHP/Library/Org/Kudian/Config.php | 1 + ThinkPHP/Library/Org/Kudian/Log.php | 12 ++++++++++++ ThinkPHP/Library/Org/Kudian/Request/Request.php | 2 +- ThinkPHP/Library/Org/Kudian/Response.php | 2 ++ ThinkPHP/Library/Org/Kudian/Sign.php | 2 ++ 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ThinkPHP/Library/Org/Kudian/Log.php diff --git a/ThinkPHP/Library/Org/Kudian/Client.php b/ThinkPHP/Library/Org/Kudian/Client.php index 3d973ab..6181ca8 100644 --- a/ThinkPHP/Library/Org/Kudian/Client.php +++ b/ThinkPHP/Library/Org/Kudian/Client.php @@ -11,7 +11,9 @@ class Client $response = ''; try { $response = $this->post($request->getUrl(), $request->getParams()); + Log::write('REQUEST_RESPONSE: ' . $response); } catch (Exception $e) { + Log::write('REQUEST_ERROR: ' . $e->getMessage()); $response = json_encode([ 'code' => -999, 'msg' => '网络错误', @@ -25,6 +27,8 @@ class Client public function post($url, $params): string { + Log::write('REQUEST_URL: ' . json_encode($url)); + Log::write('REQUEST_DATA: ' . json_encode($params)); $curl = curl_init(); if (stripos($url, 'https://') !== false){ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); diff --git a/ThinkPHP/Library/Org/Kudian/Config.php b/ThinkPHP/Library/Org/Kudian/Config.php index 6a54432..d66830a 100644 --- a/ThinkPHP/Library/Org/Kudian/Config.php +++ b/ThinkPHP/Library/Org/Kudian/Config.php @@ -4,6 +4,7 @@ namespace Org\Kudian; class Config { private static $params = [ + 'base_url' => 'https://pay.kudianvip.com', 'mch_id' => 'KP10009694', 'secret_key' => 'q5zZyyA071zS0SZR6xcz0gP0fFhtojqq', ]; diff --git a/ThinkPHP/Library/Org/Kudian/Log.php b/ThinkPHP/Library/Org/Kudian/Log.php new file mode 100644 index 0000000..0313c82 --- /dev/null +++ b/ThinkPHP/Library/Org/Kudian/Log.php @@ -0,0 +1,12 @@ +url; + return Config::get('base_url') . $this->url; } } \ No newline at end of file diff --git a/ThinkPHP/Library/Org/Kudian/Response.php b/ThinkPHP/Library/Org/Kudian/Response.php index 818984e..1ac85df 100644 --- a/ThinkPHP/Library/Org/Kudian/Response.php +++ b/ThinkPHP/Library/Org/Kudian/Response.php @@ -24,8 +24,10 @@ class Response { $data = null; if (is_array($response)) { + Log::write('RESPONSE_ARRAY: ' . json_encode($response)); $data = $response; } else { + Log::write('RESPONSE_STR: ' . $response); $data = json_decode($response); } if (!$data) { diff --git a/ThinkPHP/Library/Org/Kudian/Sign.php b/ThinkPHP/Library/Org/Kudian/Sign.php index 0c044c5..b80ecd7 100644 --- a/ThinkPHP/Library/Org/Kudian/Sign.php +++ b/ThinkPHP/Library/Org/Kudian/Sign.php @@ -7,6 +7,7 @@ class Sign public static function generate($params, $secretKey) { + Log::write('SIGN_PARAMS: ' . json_encode($params)); unset($params[self::SIGN_KEY]); ksort($params); $signStr = ''; @@ -14,6 +15,7 @@ class Sign $signStr .= $key . "=" . $value . "&"; } $signStr = rtrim($signStr, '&') . "&secret_key=" . $secretKey; + Log::write('SIGN_STR: ' . $signStr); $sign = md5($signStr); $sign = strtoupper($sign); return $sign;