@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('INVALID_GATEWAY: '.$message, $raw, self::INVALID_GATEWAY); |
|
17 | + parent::__construct('INVALID_GATEWAY: ' . $message, $raw, self::INVALID_GATEWAY); |
|
18 | 18 | } |
19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('INVALID_SIGN: '.$message, $raw, self::INVALID_SIGN); |
|
17 | + parent::__construct('INVALID_SIGN: ' . $message, $raw, self::INVALID_SIGN); |
|
18 | 18 | } |
19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('ERROR_BUSINESS: '.$message, $raw, self::ERROR_BUSINESS); |
|
17 | + parent::__construct('ERROR_BUSINESS: ' . $message, $raw, self::ERROR_BUSINESS); |
|
18 | 18 | } |
19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('INVALID_CONFIG: '.$message, $raw, self::INVALID_CONFIG); |
|
17 | + parent::__construct('INVALID_CONFIG: ' . $message, $raw, self::INVALID_CONFIG); |
|
18 | 18 | } |
19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('ERROR_GATEWAY: '.$message, $raw, self::ERROR_GATEWAY); |
|
17 | + parent::__construct('ERROR_GATEWAY: ' . $message, $raw, self::ERROR_GATEWAY); |
|
18 | 18 | } |
19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('INVALID_ARGUMENT: '.$message, $raw, self::INVALID_ARGUMENT); |
|
17 | + parent::__construct('INVALID_ARGUMENT: ' . $message, $raw, self::INVALID_ARGUMENT); |
|
18 | 18 | } |
19 | 19 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data)); |
127 | 127 | |
128 | - $data = array_filter($data, function ($value) { |
|
128 | + $data = array_filter($data, function($value) { |
|
129 | 129 | return ($value == '' || is_null($value)) ? false : true; |
130 | 130 | }); |
131 | 131 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | |
135 | 135 | Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Alipay', '', self::$instance->getBaseUri(), $result)); |
136 | 136 | |
137 | - $method = str_replace('.', '_', $data['method']).'_response'; |
|
137 | + $method = str_replace('.', '_', $data['method']) . '_response'; |
|
138 | 138 | |
139 | 139 | if (!isset($result['sign']) || $result[$method]['code'] != '10000') { |
140 | 140 | throw new GatewayException( |
141 | - 'Get Alipay API Error:'.$result[$method]['msg'].($result[$method]['sub_code'] ?? ''), |
|
141 | + 'Get Alipay API Error:' . $result[$method]['msg'] . ($result[$method]['sub_code'] ?? ''), |
|
142 | 142 | $result |
143 | 143 | ); |
144 | 144 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | |
174 | 174 | if (Str::endsWith($privateKey, '.pem')) { |
175 | 175 | $privateKey = openssl_pkey_get_private($privateKey); |
176 | - } else { |
|
177 | - $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n". |
|
178 | - wordwrap($privateKey, 64, "\n", true). |
|
176 | + }else { |
|
177 | + $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
178 | + wordwrap($privateKey, 64, "\n", true) . |
|
179 | 179 | "\n-----END RSA PRIVATE KEY-----"; |
180 | 180 | } |
181 | 181 | |
@@ -211,16 +211,15 @@ discard block |
||
211 | 211 | |
212 | 212 | if (Str::endsWith($publicKey, '.pem')) { |
213 | 213 | $publicKey = openssl_pkey_get_public($publicKey); |
214 | - } else { |
|
215 | - $publicKey = "-----BEGIN PUBLIC KEY-----\n". |
|
216 | - wordwrap($publicKey, 64, "\n", true). |
|
214 | + }else { |
|
215 | + $publicKey = "-----BEGIN PUBLIC KEY-----\n" . |
|
216 | + wordwrap($publicKey, 64, "\n", true) . |
|
217 | 217 | "\n-----END PUBLIC KEY-----"; |
218 | 218 | } |
219 | 219 | |
220 | 220 | $sign = $sign ?? $data['sign']; |
221 | 221 | |
222 | - $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : |
|
223 | - self::getSignContent($data, true); |
|
222 | + $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : self::getSignContent($data, true); |
|
224 | 223 | |
225 | 224 | return openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1; |
226 | 225 | } |
@@ -244,10 +243,10 @@ discard block |
||
244 | 243 | $stringToBeSigned = ''; |
245 | 244 | foreach ($data as $k => $v) { |
246 | 245 | if ($verify && $k != 'sign' && $k != 'sign_type') { |
247 | - $stringToBeSigned .= $k.'='.$v.'&'; |
|
246 | + $stringToBeSigned .= $k . '=' . $v . '&'; |
|
248 | 247 | } |
249 | 248 | if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) { |
250 | - $stringToBeSigned .= $k.'='.$v.'&'; |
|
249 | + $stringToBeSigned .= $k . '=' . $v . '&'; |
|
251 | 250 | } |
252 | 251 | } |
253 | 252 |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $payload['appid'] = self::$instance->getConfig($type, ''); |
232 | 232 | |
233 | 233 | if (self::$instance->getConfig('mode', Wechat::MODE_NORMAL) === Wechat::MODE_SERVICE) { |
234 | - $payload['sub_appid'] = self::$instance->getConfig('sub_'.$type, ''); |
|
234 | + $payload['sub_appid'] = self::$instance->getConfig('sub_' . $type, ''); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | unset($payload['trade_type'], $payload['type']); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | ksort($data); |
267 | 267 | |
268 | - $string = md5(self::getSignContent($data).'&key='.$key); |
|
268 | + $string = md5(self::getSignContent($data) . '&key=' . $key); |
|
269 | 269 | |
270 | 270 | Log::debug('Wechat Generate Sign Before UPPER', [$data, $string]); |
271 | 271 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $buff = ''; |
287 | 287 | |
288 | 288 | foreach ($data as $k => $v) { |
289 | - $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
289 | + $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | Log::debug('Wechat Generate Sign Content Before Trim', [$data, $buff]); |
@@ -332,8 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | $xml = '<xml>'; |
334 | 334 | foreach ($data as $key => $val) { |
335 | - $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' : |
|
336 | - '<'.$key.'><![CDATA['.$val.']]></'.$key.'>'; |
|
335 | + $xml .= is_numeric($val) ? '<' . $key . '>' . $val . '</' . $key . '>' : '<' . $key . '><![CDATA[' . $val . ']]></' . $key . '>'; |
|
337 | 336 | } |
338 | 337 | $xml .= '</xml>'; |
339 | 338 | |
@@ -404,7 +403,7 @@ discard block |
||
404 | 403 | $type = 'appid'; |
405 | 404 | break; |
406 | 405 | default: |
407 | - $type = $type.'_id'; |
|
406 | + $type = $type . '_id'; |
|
408 | 407 | } |
409 | 408 | |
410 | 409 | return $type; |
@@ -440,7 +439,7 @@ discard block |
||
440 | 439 | { |
441 | 440 | if (!isset($result['return_code']) || $result['return_code'] != 'SUCCESS') { |
442 | 441 | throw new GatewayException( |
443 | - 'Get Wechat API Error:'.($result['return_msg'] ?? $result['retmsg']), |
|
442 | + 'Get Wechat API Error:' . ($result['return_msg'] ?? $result['retmsg']), |
|
444 | 443 | $result |
445 | 444 | ); |
446 | 445 | } |
@@ -451,7 +450,7 @@ discard block |
||
451 | 450 | |
452 | 451 | if ($result['result_code'] != 'SUCCESS') { |
453 | 452 | throw new BusinessException( |
454 | - 'Wechat Business Error: '.$result['err_code'].' - '.$result['err_code_des'], |
|
453 | + 'Wechat Business Error: ' . $result['err_code'] . ' - ' . $result['err_code_des'], |
|
455 | 454 | $result |
456 | 455 | ); |
457 | 456 | } |