@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | return file_get_contents($key); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - return "-----BEGIN RSA PRIVATE KEY-----\n". |
|
| 50 | - wordwrap($key, 64, "\n", true). |
|
| 49 | + return "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
| 50 | + wordwrap($key, 64, "\n", true) . |
|
| 51 | 51 | "\n-----END RSA PRIVATE KEY-----"; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | return $url; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
| 158 | + return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | function get_wechat_type_key(array $params): string |
| 176 | 176 | { |
| 177 | - $key = ($params['_type'] ?? 'mp').'_app_id'; |
|
| 177 | + $key = ($params['_type'] ?? 'mp') . '_app_id'; |
|
| 178 | 178 | |
| 179 | 179 | if ('app_app_id' === $key) { |
| 180 | 180 | $key = 'app_id'; |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | $buff = ''; |
| 218 | 218 | |
| 219 | 219 | foreach ($payload as $k => $v) { |
| 220 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
| 220 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $sign = md5($buff.'key='.$key); |
|
| 223 | + $sign = md5($buff . 'key=' . $key); |
|
| 224 | 224 | |
| 225 | 225 | return $upper ? strtoupper($sign) : $sign; |
| 226 | 226 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @throws InvalidSignException |
| 234 | 234 | * @throws ServiceNotFoundException |
| 235 | 235 | */ |
| 236 | -function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void |
|
| 236 | +function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void |
|
| 237 | 237 | { |
| 238 | 238 | if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) { |
| 239 | 239 | return; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $sign = $message->getHeaderLine('Wechatpay-Signature'); |
| 246 | 246 | $body = (string) $message->getBody(); |
| 247 | 247 | |
| 248 | - $content = $timestamp."\n".$random."\n".$body."\n"; |
|
| 248 | + $content = $timestamp . "\n" . $random . "\n" . $body . "\n"; |
|
| 249 | 249 | $public = get_provider_config('wechat', $params)['wechat_public_cert_path'][$wechatSerial] ?? null; |
| 250 | 250 | |
| 251 | 251 | if (empty($sign)) { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | Pay::get(ConfigInterface::class)->set( |
| 333 | - 'wechat.'.get_tenant($params).'.wechat_public_cert_path', |
|
| 333 | + 'wechat.' . get_tenant($params) . '.wechat_public_cert_path', |
|
| 334 | 334 | ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []), |
| 335 | 335 | ); |
| 336 | 336 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) { |
| 364 | - file_put_contents($path.'/'.$serialNo.'.crt', $cert); |
|
| 364 | + file_put_contents($path . '/' . $serialNo . '.crt', $cert); |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | /** |
| 394 | 394 | * @throws DecryptException |
| 395 | 395 | */ |
| 396 | -function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string |
|
| 396 | +function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string |
|
| 397 | 397 | { |
| 398 | 398 | $decrypted = openssl_decrypt( |
| 399 | 399 | substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE), |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null; |
| 455 | 455 | |
| 456 | 456 | if (empty($publicKey)) { |
| 457 | - throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -'.$serialNo); |
|
| 457 | + throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -' . $serialNo); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return $publicKey; |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | throw new InvalidConfigException(Exception::CONFIG_WECHAT_INVALID, '配置异常: 缺少微信配置 -- [mini_app_key_virtual_pay]'); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - return hash_hmac('sha256', $url.'&'.$payload, $config['mini_app_key_virtual_pay']); |
|
| 472 | + return hash_hmac('sha256', $url . '&' . $payload, $config['mini_app_key_virtual_pay']); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | function get_wechat_miniprogram_user_sign(string $sessionKey, string $payload): string |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | return $url; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
| 533 | + return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
@@ -563,10 +563,10 @@ discard block |
||
| 563 | 563 | $buff = ''; |
| 564 | 564 | |
| 565 | 565 | foreach ($payload as $k => $v) { |
| 566 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
| 566 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - return strtoupper(md5($buff.'key='.$key)); |
|
| 569 | + return strtoupper(md5($buff . 'key=' . $key)); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | /** |