@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | HttpServiceProvider::class, |
| 72 | 72 | ]; |
| 73 | 73 | |
| 74 | - private static null|Closure|ContainerInterface $container = null; |
|
| 74 | + private static null | Closure | ContainerInterface $container = null; |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @throws ContainerException |
| 78 | 78 | */ |
| 79 | - private function __construct(array $config, Closure|ContainerInterface $container = null) |
|
| 79 | + private function __construct(array $config, Closure | ContainerInterface $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 = [], Closure|ContainerInterface $container = null): bool |
|
| 105 | + public static function config(array $config = [], Closure | ContainerInterface $container = null): bool |
|
| 106 | 106 | { |
| 107 | 107 | if (self::hasContainer() && !($config['_force'] ?? false)) { |
| 108 | 108 | return false; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } catch (ContainerNotFoundException $e) { |
| 138 | 138 | throw $e; |
| 139 | 139 | } catch (Throwable $e) { |
| 140 | - throw new ContainerException('容器异常: '.$e->getMessage()); |
|
| 140 | + throw new ContainerException('容器异常: ' . $e->getMessage()); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | throw new ContainerException('容器异常: 当前容器类型不支持 `set` 方法'); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } catch (ContainerNotFoundException $e) { |
| 160 | 160 | throw $e; |
| 161 | 161 | } catch (Throwable $e) { |
| 162 | - throw new ContainerException('容器异常: '.$e->getMessage()); |
|
| 162 | + throw new ContainerException('容器异常: ' . $e->getMessage()); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $parameters = array_values($parameters); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | try { |
| 177 | 177 | return Pay::getContainer()->get($service); |
| 178 | 178 | } catch (NotFoundExceptionInterface $e) { |
| 179 | - throw new ServiceNotFoundException('服务未找到: '.$e->getMessage()); |
|
| 179 | + throw new ServiceNotFoundException('服务未找到: ' . $e->getMessage()); |
|
| 180 | 180 | } catch (ContainerNotFoundException $e) { |
| 181 | 181 | throw $e; |
| 182 | 182 | } catch (Throwable $e) { |
| 183 | - throw new ContainerException('容器异常: '.$e->getMessage()); |
|
| 183 | + throw new ContainerException('容器异常: ' . $e->getMessage()); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | return Pay::getContainer()->has($service); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public static function setContainer(null|Closure|ContainerInterface $container): void |
|
| 195 | + public static function setContainer(null | Closure | ContainerInterface $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, Closure|ContainerInterface $container = null): void |
|
| 241 | + private function registerServices(array $config, Closure | ContainerInterface $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); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $direction = Pay::get($direction); |
| 49 | 49 | |
| 50 | 50 | $direction = is_string($direction) ? Pay::get($direction) : $direction; |
| 51 | - } catch (ContainerException|ServiceNotFoundException) { |
|
| 51 | + } catch (ContainerException | ServiceNotFoundException) { |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if (!$direction instanceof DirectionInterface) { |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | return file_get_contents($key); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return "-----BEGIN RSA PRIVATE KEY-----\n". |
|
| 73 | - wordwrap($key, 64, "\n", true). |
|
| 72 | + return "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
| 73 | + wordwrap($key, 64, "\n", true) . |
|
| 74 | 74 | "\n-----END RSA PRIVATE KEY-----"; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return $url; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
| 156 | + return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | function get_wechat_config_type_key(array $params): string |
| 174 | 174 | { |
| 175 | - $key = ($params['_type'] ?? 'mp').'_app_id'; |
|
| 175 | + $key = ($params['_type'] ?? 'mp') . '_app_id'; |
|
| 176 | 176 | |
| 177 | 177 | if ('app_app_id' === $key) { |
| 178 | 178 | $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_wechat_config($params)['wechat_public_cert_path'][$wechatSerial] ?? null; |
| 250 | 250 | |
| 251 | 251 | if (empty($sign)) { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | Pay::get(ConfigInterface::class)->set( |
| 301 | - 'wechat.'.get_tenant($params).'.wechat_public_cert_path', |
|
| 301 | + 'wechat.' . get_tenant($params) . '.wechat_public_cert_path', |
|
| 302 | 302 | ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []), |
| 303 | 303 | ); |
| 304 | 304 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) { |
| 332 | - file_put_contents($path.'/'.$serialNo.'.crt', $cert); |
|
| 332 | + file_put_contents($path . '/' . $serialNo . '.crt', $cert); |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | /** |
| 362 | 362 | * @throws DecryptException |
| 363 | 363 | */ |
| 364 | -function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string |
|
| 364 | +function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string |
|
| 365 | 365 | { |
| 366 | 366 | $decrypted = openssl_decrypt( |
| 367 | 367 | substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE), |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | $publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null; |
| 423 | 423 | |
| 424 | 424 | if (empty($publicKey)) { |
| 425 | - throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -'.$serialNo); |
|
| 425 | + throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -' . $serialNo); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | return $publicKey; |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | return $this->combinePlugins(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $action = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
| 43 | + $action = Str::camel($params['_action'] ?? 'default') . 'Plugins'; |
|
| 44 | 44 | |
| 45 | 45 | if (method_exists($this, $action)) { |
| 46 | 46 | return $this->{$action}(); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function getPlugins(array $params): array |
| 31 | 31 | { |
| 32 | - $action = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
| 32 | + $action = Str::camel($params['_action'] ?? 'default') . 'Plugins'; |
|
| 33 | 33 | |
| 34 | 34 | if (method_exists($this, $action)) { |
| 35 | 35 | return $this->{$action}(); |
@@ -20,17 +20,17 @@ |
||
| 20 | 20 | * @throws InvalidParamsException |
| 21 | 21 | * @throws ServiceNotFoundException |
| 22 | 22 | */ |
| 23 | - public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket; |
|
| 23 | + public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket; |
|
| 24 | 24 | |
| 25 | - public function query(array $order): Collection|Rocket; |
|
| 25 | + public function query(array $order): Collection | Rocket; |
|
| 26 | 26 | |
| 27 | - public function cancel(array $order): Collection|Rocket; |
|
| 27 | + public function cancel(array $order): Collection | Rocket; |
|
| 28 | 28 | |
| 29 | - public function close(array $order): Collection|Rocket; |
|
| 29 | + public function close(array $order): Collection | Rocket; |
|
| 30 | 30 | |
| 31 | - public function refund(array $order): Collection|Rocket; |
|
| 31 | + public function refund(array $order): Collection | Rocket; |
|
| 32 | 32 | |
| 33 | - public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection|Rocket; |
|
| 33 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection | Rocket; |
|
| 34 | 34 | |
| 35 | 35 | public function success(): ResponseInterface; |
| 36 | 36 | } |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | private string $direction = DirectionInterface::class; |
| 34 | 34 | |
| 35 | - private null|Collection|MessageInterface $destination = null; |
|
| 35 | + private null | Collection | MessageInterface $destination = null; |
|
| 36 | 36 | |
| 37 | - private null|RequestInterface|ResponseInterface $destinationOrigin = null; |
|
| 37 | + private null | RequestInterface | ResponseInterface $destinationOrigin = null; |
|
| 38 | 38 | |
| 39 | 39 | public function getRadar(): ?RequestInterface |
| 40 | 40 | { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | return $this->payload; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function setPayload(null|array|Collection $payload): Rocket |
|
| 75 | + public function setPayload(null | array | Collection $payload): Rocket |
|
| 76 | 76 | { |
| 77 | 77 | if (is_array($payload)) { |
| 78 | 78 | $payload = new Collection($payload); |
@@ -118,24 +118,24 @@ discard block |
||
| 118 | 118 | return $this; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function getDestination(): null|Collection|MessageInterface |
|
| 121 | + public function getDestination(): null | Collection | MessageInterface |
|
| 122 | 122 | { |
| 123 | 123 | return $this->destination; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function setDestination(null|Collection|MessageInterface $destination): Rocket |
|
| 126 | + public function setDestination(null | Collection | MessageInterface $destination): Rocket |
|
| 127 | 127 | { |
| 128 | 128 | $this->destination = $destination; |
| 129 | 129 | |
| 130 | 130 | return $this; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function getDestinationOrigin(): null|RequestInterface|ResponseInterface |
|
| 133 | + public function getDestinationOrigin(): null | RequestInterface | ResponseInterface |
|
| 134 | 134 | { |
| 135 | 135 | return $this->destinationOrigin; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function setDestinationOrigin(null|RequestInterface|ResponseInterface $destinationOrigin): Rocket |
|
| 138 | + public function setDestinationOrigin(null | RequestInterface | ResponseInterface $destinationOrigin): Rocket |
|
| 139 | 139 | { |
| 140 | 140 | $this->destinationOrigin = $destinationOrigin; |
| 141 | 141 | |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | $urlPath = parse_url($url, PHP_URL_PATH); |
| 62 | 62 | $urlQuery = parse_url($url, PHP_URL_QUERY); |
| 63 | 63 | |
| 64 | - return get_wechat_method($payload)."\n". |
|
| 65 | - $urlPath.(empty($urlQuery) ? '' : '?'.$urlQuery)."\n". |
|
| 66 | - $timestamp."\n". |
|
| 67 | - $random."\n". |
|
| 68 | - get_wechat_body($payload)."\n"; |
|
| 64 | + return get_wechat_method($payload) . "\n" . |
|
| 65 | + $urlPath . (empty($urlQuery) ? '' : '?' . $urlQuery) . "\n" . |
|
| 66 | + $timestamp . "\n" . |
|
| 67 | + $random . "\n" . |
|
| 68 | + get_wechat_body($payload) . "\n"; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -94,6 +94,6 @@ discard block |
||
| 94 | 94 | get_wechat_sign($config, $contents), |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - return 'WECHATPAY2-SHA256-RSA2048 '.$auth; |
|
| 97 | + return 'WECHATPAY2-SHA256-RSA2048 ' . $auth; |
|
| 98 | 98 | } |
| 99 | 99 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $rocket->mergePayload(array_merge( |
| 43 | 43 | [ |
| 44 | 44 | '_method' => 'POST', |
| 45 | - '_service_url' => 'v3/ecommerce/refunds/'.$refundId.'/return-advance', |
|
| 45 | + '_service_url' => 'v3/ecommerce/refunds/' . $refundId . '/return-advance', |
|
| 46 | 46 | ], |
| 47 | 47 | $this->service($payload, $config) |
| 48 | 48 | )); |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | |
| 41 | 41 | $rocket->setPayload([ |
| 42 | 42 | '_method' => 'GET', |
| 43 | - '_service_url' => 'v3/ecommerce/refunds/'.$refundId.'/return-advance?sub_mchid='.$payload->get('sub_mchid', $config['sub_mch_id']), |
|
| 43 | + '_service_url' => 'v3/ecommerce/refunds/' . $refundId . '/return-advance?sub_mchid=' . $payload->get('sub_mchid', $config['sub_mch_id']), |
|
| 44 | 44 | ]); |
| 45 | 45 | |
| 46 | 46 | Logger::info('[Wechat][Marketing][ECommerceRefund][QueryReturnAdvancePlugin] 插件装载完毕', ['rocket' => $rocket]); |