@@ -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 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return $url; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
| 144 | + return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | function get_wechat_type_key(array $params): string |
| 162 | 162 | { |
| 163 | - $key = ($params['_type'] ?? 'mp').'_app_id'; |
|
| 163 | + $key = ($params['_type'] ?? 'mp') . '_app_id'; |
|
| 164 | 164 | |
| 165 | 165 | if ('app_app_id' === $key) { |
| 166 | 166 | $key = 'app_id'; |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | $buff = ''; |
| 204 | 204 | |
| 205 | 205 | foreach ($payload as $k => $v) { |
| 206 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
| 206 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $sign = md5($buff.'key='.$key); |
|
| 209 | + $sign = md5($buff . 'key=' . $key); |
|
| 210 | 210 | |
| 211 | 211 | return $upper ? strtoupper($sign) : $sign; |
| 212 | 212 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @throws InvalidSignException |
| 220 | 220 | * @throws ServiceNotFoundException |
| 221 | 221 | */ |
| 222 | -function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void |
|
| 222 | +function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void |
|
| 223 | 223 | { |
| 224 | 224 | if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) { |
| 225 | 225 | return; |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $sign = $message->getHeaderLine('Wechatpay-Signature'); |
| 232 | 232 | $body = (string) $message->getBody(); |
| 233 | 233 | |
| 234 | - $content = $timestamp."\n".$random."\n".$body."\n"; |
|
| 234 | + $content = $timestamp . "\n" . $random . "\n" . $body . "\n"; |
|
| 235 | 235 | $public = get_wechat_config($params)['wechat_public_cert_path'][$wechatSerial] ?? null; |
| 236 | 236 | |
| 237 | 237 | if (empty($sign)) { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | Pay::get(ConfigInterface::class)->set( |
| 319 | - 'wechat.'.get_tenant($params).'.wechat_public_cert_path', |
|
| 319 | + 'wechat.' . get_tenant($params) . '.wechat_public_cert_path', |
|
| 320 | 320 | ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []), |
| 321 | 321 | ); |
| 322 | 322 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) { |
| 350 | - file_put_contents($path.'/'.$serialNo.'.crt', $cert); |
|
| 350 | + file_put_contents($path . '/' . $serialNo . '.crt', $cert); |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | /** |
| 380 | 380 | * @throws DecryptException |
| 381 | 381 | */ |
| 382 | -function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string |
|
| 382 | +function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string |
|
| 383 | 383 | { |
| 384 | 384 | $decrypted = openssl_decrypt( |
| 385 | 385 | substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE), |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | $publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null; |
| 441 | 441 | |
| 442 | 442 | if (empty($publicKey)) { |
| 443 | - throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -'.$serialNo); |
|
| 443 | + throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -' . $serialNo); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | return $publicKey; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | throw new InvalidConfigException(Exception::CONFIG_WECHAT_INVALID, '配置异常: 缺少微信配置 -- [mini_app_key_virtual_pay]'); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - return hash_hmac('sha256', $url.'&'.$payload, $config['mini_app_key_virtual_pay']); |
|
| 458 | + return hash_hmac('sha256', $url . '&' . $payload, $config['mini_app_key_virtual_pay']); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | function get_wechat_miniprogram_user_sign(string $sessionKey, string $payload): string |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | return $url; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
| 518 | + return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | $buff = ''; |
| 549 | 549 | |
| 550 | 550 | foreach ($payload as $k => $v) { |
| 551 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
| 551 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - return strtoupper(md5($buff.'key='.$key)); |
|
| 554 | + return strtoupper(md5($buff . 'key=' . $key)); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /** |