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;