@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | return file_get_contents($key); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - return "-----BEGIN RSA PRIVATE KEY-----\n". |
|
| 67 | - wordwrap($key, 64, "\n", true). |
|
| 66 | + return "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
| 67 | + wordwrap($key, 64, "\n", true) . |
|
| 68 | 68 | "\n-----END RSA PRIVATE KEY-----"; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | $buff = ''; |
| 165 | 165 | |
| 166 | 166 | foreach ($payload as $k => $v) { |
| 167 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
| 167 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $sign = md5($buff.'key='.$key); |
|
| 170 | + $sign = md5($buff . 'key=' . $key); |
|
| 171 | 171 | |
| 172 | 172 | return $upper ? strtoupper($sign) : $sign; |
| 173 | 173 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @throws ServiceNotFoundException |
| 182 | 182 | * @throws InvalidParamsException |
| 183 | 183 | */ |
| 184 | - function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void |
|
| 184 | + function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void |
|
| 185 | 185 | { |
| 186 | 186 | if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) { |
| 187 | 187 | return; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $sign = $message->getHeaderLine('Wechatpay-Signature'); |
| 194 | 194 | $body = (string) $message->getBody(); |
| 195 | 195 | |
| 196 | - $content = $timestamp."\n".$random."\n".$body."\n"; |
|
| 196 | + $content = $timestamp . "\n" . $random . "\n" . $body . "\n"; |
|
| 197 | 197 | $public = get_wechat_config($params)['wechat_public_cert_path'][$wechatSerial] ?? null; |
| 198 | 198 | |
| 199 | 199 | if (empty($sign)) { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $wechatConfig = get_wechat_config($params); |
| 251 | 251 | |
| 252 | 252 | Pay::get(ConfigInterface::class)->set( |
| 253 | - 'wechat.'.get_tenant($params).'.wechat_public_cert_path', |
|
| 253 | + 'wechat.' . get_tenant($params) . '.wechat_public_cert_path', |
|
| 254 | 254 | ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []), |
| 255 | 255 | ); |
| 256 | 256 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) { |
| 286 | - file_put_contents($path.'/'.$serialNo.'.crt', $cert); |
|
| 286 | + file_put_contents($path . '/' . $serialNo . '.crt', $cert); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | /** |
| 322 | 322 | * @throws InvalidResponseException |
| 323 | 323 | */ |
| 324 | - function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string |
|
| 324 | + function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string |
|
| 325 | 325 | { |
| 326 | 326 | $decrypted = openssl_decrypt( |
| 327 | 327 | substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE), |
@@ -23,8 +23,7 @@ discard block |
||
| 23 | 23 | $radar = $rocket->getRadar(); |
| 24 | 24 | |
| 25 | 25 | $response = 'GET' === $radar->getMethod() ? |
| 26 | - $this->buildRedirect($radar->getUri()->__toString(), $rocket->getPayload()) : |
|
| 27 | - $this->buildHtml($radar->getUri()->__toString(), $rocket->getPayload()); |
|
| 26 | + $this->buildRedirect($radar->getUri()->__toString(), $rocket->getPayload()) : $this->buildHtml($radar->getUri()->__toString(), $rocket->getPayload()); |
|
| 28 | 27 | |
| 29 | 28 | $rocket->setDestination($response); |
| 30 | 29 | |
@@ -35,7 +34,7 @@ discard block |
||
| 35 | 34 | |
| 36 | 35 | protected function buildRedirect(string $endpoint, Collection $payload): Response |
| 37 | 36 | { |
| 38 | - $url = $endpoint.(!str_contains($endpoint, '?') ? '?' : '&').$payload->query(); |
|
| 37 | + $url = $endpoint . (!str_contains($endpoint, '?') ? '?' : '&') . $payload->query(); |
|
| 39 | 38 | |
| 40 | 39 | $content = sprintf( |
| 41 | 40 | '<!DOCTYPE html> |
@@ -58,10 +57,10 @@ discard block |
||
| 58 | 57 | |
| 59 | 58 | protected function buildHtml(string $endpoint, Collection $payload): Response |
| 60 | 59 | { |
| 61 | - $sHtml = "<form id='alipay_submit' name='alipay_submit' action='".$endpoint."' method='POST'>"; |
|
| 60 | + $sHtml = "<form id='alipay_submit' name='alipay_submit' action='" . $endpoint . "' method='POST'>"; |
|
| 62 | 61 | foreach ($payload->all() as $key => $val) { |
| 63 | 62 | $val = str_replace("'", ''', $val); |
| 64 | - $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>"; |
|
| 63 | + $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; |
|
| 65 | 64 | } |
| 66 | 65 | $sHtml .= "<input type='submit' value='ok' style='display:none;'></form>"; |
| 67 | 66 | $sHtml .= "<script>document.forms['alipay_submit'].submit();</script>"; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $url = Pay::MODE_SERVICE === (get_wechat_config($params)['mode'] ?? null) ? $this->getPartnerUri($rocket) : $this->getUri($rocket); |
| 65 | 65 | |
| 66 | - return str_starts_with($url, 'http') ? $url : (get_wechat_base_uri($params).$url); |
|
| 66 | + return str_starts_with($url, 'http') ? $url : (get_wechat_base_uri($params) . $url); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | protected function getHeaders(): array |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | protected function getConfigKey(array $params): string |
| 79 | 79 | { |
| 80 | - $key = ($params['_type'] ?? 'mp').'_app_id'; |
|
| 80 | + $key = ($params['_type'] ?? 'mp') . '_app_id'; |
|
| 81 | 81 | |
| 82 | 82 | if ('app_app_id' === $key) { |
| 83 | 83 | $key = 'app_id'; |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | /** |
| 52 | 52 | * @throws InvalidResponseException |
| 53 | 53 | */ |
| 54 | - protected function validateResponse(Rocket $rocket): Collection|MessageInterface|array|null |
|
| 54 | + protected function validateResponse(Rocket $rocket): Collection | MessageInterface | array | null |
|
| 55 | 55 | { |
| 56 | 56 | $response = $rocket->getDestination(); |
| 57 | 57 | |
@@ -19,17 +19,17 @@ |
||
| 19 | 19 | * @throws InvalidParamsException |
| 20 | 20 | * @throws ServiceNotFoundException |
| 21 | 21 | */ |
| 22 | - public function pay(array $plugins, array $params): Collection|MessageInterface|array|null; |
|
| 22 | + public function pay(array $plugins, array $params): Collection | MessageInterface | array | null; |
|
| 23 | 23 | |
| 24 | - public function find(array|string $order): Collection|array; |
|
| 24 | + public function find(array | string $order): Collection | array; |
|
| 25 | 25 | |
| 26 | - public function cancel(array|string $order): array|Collection|null; |
|
| 26 | + public function cancel(array | string $order): array | Collection | null; |
|
| 27 | 27 | |
| 28 | - public function close(array|string $order): array|Collection|null; |
|
| 28 | + public function close(array | string $order): array | Collection | null; |
|
| 29 | 29 | |
| 30 | - public function refund(array $order): Collection|array; |
|
| 30 | + public function refund(array $order): Collection | array; |
|
| 31 | 31 | |
| 32 | - public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection; |
|
| 32 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection; |
|
| 33 | 33 | |
| 34 | 34 | public function success(): ResponseInterface; |
| 35 | 35 | } |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | HttpServiceProvider::class, |
| 72 | 72 | ]; |
| 73 | 73 | |
| 74 | - private static Closure|null|ContainerInterface $container; |
|
| 74 | + private static Closure | null | ContainerInterface $container; |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @throws ContainerException |
| 78 | 78 | */ |
| 79 | - private function __construct(array $config, ContainerInterface|Closure $container = null) |
|
| 79 | + private function __construct(array $config, ContainerInterface | Closure $container = null) |
|
| 80 | 80 | { |
| 81 | 81 | $this->registerServices($config, $container); |
| 82 | 82 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | /** |
| 103 | 103 | * @throws ContainerException |
| 104 | 104 | */ |
| 105 | - public static function config(array $config = [], ContainerInterface|Closure $container = null): bool |
|
| 105 | + public static function config(array $config = [], ContainerInterface | Closure $container = null): bool |
|
| 106 | 106 | { |
| 107 | 107 | if (self::hasContainer() && !($config['_force'] ?? false)) { |
| 108 | 108 | return false; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | return Pay::getContainer()->has($service); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public static function setContainer(ContainerInterface|Closure|null $container): void |
|
| 195 | + public static function setContainer(ContainerInterface | Closure | null $container): void |
|
| 196 | 196 | { |
| 197 | 197 | self::$container = $container; |
| 198 | 198 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | /** |
| 239 | 239 | * @throws ContainerException |
| 240 | 240 | */ |
| 241 | - private function registerServices(array $config, ContainerInterface|Closure $container = null): void |
|
| 241 | + private function registerServices(array $config, ContainerInterface | Closure $container = null): void |
|
| 242 | 242 | { |
| 243 | 243 | foreach (array_merge($this->coreService, $this->service) as $service) { |
| 244 | 244 | self::registerService($service, ContainerServiceProvider::class == $service ? $container : $config); |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | |
| 62 | 62 | protected function getDefaultHandler(): AbstractProcessingHandler |
| 63 | 63 | { |
| 64 | - $file = $this->config['file'] ?? (sys_get_temp_dir().'/logs/'.$this->config['identify'].'.log'); |
|
| 64 | + $file = $this->config['file'] ?? (sys_get_temp_dir() . '/logs/' . $this->config['identify'] . '.log'); |
|
| 65 | 65 | |
| 66 | 66 | return match ($this->config['type']) { |
| 67 | 67 | 'single' => new StreamHandler($file, $this->config['level']), |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | |
| 14 | 14 | public ?array $params = null; |
| 15 | 15 | |
| 16 | - public ServerRequestInterface|array|null $contents; |
|
| 16 | + public ServerRequestInterface | array | null $contents; |
|
| 17 | 17 | |
| 18 | - public function __construct(string $provider, ServerRequestInterface|array|null $contents, ?array $params = null, ?Rocket $rocket = null) |
|
| 18 | + public function __construct(string $provider, ServerRequestInterface | array | null $contents, ?array $params = null, ?Rocket $rocket = null) |
|
| 19 | 19 | { |
| 20 | 20 | $this->provider = $provider; |
| 21 | 21 | $this->contents = $contents; |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function __call(string $shortcut, array $params) |
| 57 | 57 | { |
| 58 | - $plugin = '\\Yansongda\\Pay\\Plugin\\Wechat\\Shortcut\\'. |
|
| 59 | - Str::studly($shortcut).'Shortcut'; |
|
| 58 | + $plugin = '\\Yansongda\\Pay\\Plugin\\Wechat\\Shortcut\\' . |
|
| 59 | + Str::studly($shortcut) . 'Shortcut'; |
|
| 60 | 60 | |
| 61 | 61 | return $this->call($plugin, ...$params); |
| 62 | 62 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @throws InvalidParamsException |
| 67 | 67 | * @throws ServiceNotFoundException |
| 68 | 68 | */ |
| 69 | - public function find(array|string $order): Collection|array |
|
| 69 | + public function find(array | string $order): Collection | array |
|
| 70 | 70 | { |
| 71 | 71 | $order = is_array($order) ? $order : ['transaction_id' => $order]; |
| 72 | 72 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | /** |
| 79 | 79 | * @throws InvalidParamsException |
| 80 | 80 | */ |
| 81 | - public function cancel(array|string $order): null|Collection|array |
|
| 81 | + public function cancel(array | string $order): null | Collection | array |
|
| 82 | 82 | { |
| 83 | 83 | throw new InvalidParamsException(Exception::METHOD_NOT_SUPPORTED, 'Wechat does not support cancel api'); |
| 84 | 84 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @throws InvalidParamsException |
| 89 | 89 | * @throws ServiceNotFoundException |
| 90 | 90 | */ |
| 91 | - public function close(array|string $order): null|Collection|array |
|
| 91 | + public function close(array | string $order): null | Collection | array |
|
| 92 | 92 | { |
| 93 | 93 | $order = is_array($order) ? $order : ['out_trade_no' => $order]; |
| 94 | 94 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @throws InvalidParamsException |
| 103 | 103 | * @throws ServiceNotFoundException |
| 104 | 104 | */ |
| 105 | - public function refund(array $order): Collection|array |
|
| 105 | + public function refund(array $order): Collection | array |
|
| 106 | 106 | { |
| 107 | 107 | Event::dispatch(new Event\MethodCalled('wechat', __METHOD__, $order, null)); |
| 108 | 108 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @throws ContainerException |
| 114 | 114 | * @throws InvalidParamsException |
| 115 | 115 | */ |
| 116 | - public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection |
|
| 116 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection |
|
| 117 | 117 | { |
| 118 | 118 | $request = $this->getCallbackParams($contents); |
| 119 | 119 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - protected function getCallbackParams(null|array|ServerRequestInterface $contents = null): ServerRequestInterface |
|
| 147 | + protected function getCallbackParams(null | array | ServerRequestInterface $contents = null): ServerRequestInterface |
|
| 148 | 148 | { |
| 149 | 149 | if (is_array($contents) && isset($contents['body'], $contents['headers'])) { |
| 150 | 150 | return new ServerRequest('POST', 'http://localhost', $contents['headers'], $contents['body']); |