@@ -84,11 +84,11 @@ |
||
84 | 84 | foreach ($keys as $key) { |
85 | 85 | $val = $value[$key]; |
86 | 86 | |
87 | - $result[] = is_array($val) ? $this->arrayToString($val) : (($isJsonArray ? '' : $key.':').trim(strval($val))); |
|
87 | + $result[] = is_array($val) ? $this->arrayToString($val) : (($isJsonArray ? '' : $key . ':') . trim(strval($val))); |
|
88 | 88 | } |
89 | 89 | |
90 | - $result = '['.implode(' ', $result ?? []).']'; |
|
90 | + $result = '[' . implode(' ', $result ?? []) . ']'; |
|
91 | 91 | |
92 | - return ($isJsonArray ? '' : 'map').$result; |
|
92 | + return ($isJsonArray ? '' : 'map') . $result; |
|
93 | 93 | } |
94 | 94 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @throws InvalidParamsException |
57 | 57 | * @throws ServiceNotFoundException |
58 | 58 | */ |
59 | - public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket |
|
59 | + public function __call(string $shortcut, array $params): null | Collection | MessageInterface | Rocket |
|
60 | 60 | { |
61 | - $plugin = '\Yansongda\Pay\Shortcut\Wechat\\'.Str::studly($shortcut).'Shortcut'; |
|
61 | + $plugin = '\Yansongda\Pay\Shortcut\Wechat\\' . Str::studly($shortcut) . 'Shortcut'; |
|
62 | 62 | |
63 | 63 | return Artful::shortcut($plugin, ...$params); |
64 | 64 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @throws ContainerException |
68 | 68 | * @throws InvalidParamsException |
69 | 69 | */ |
70 | - public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket |
|
70 | + public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket |
|
71 | 71 | { |
72 | 72 | return Artful::artful($plugins, $params); |
73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws InvalidParamsException |
78 | 78 | * @throws ServiceNotFoundException |
79 | 79 | */ |
80 | - public function query(array $order): Collection|Rocket |
|
80 | + public function query(array $order): Collection | Rocket |
|
81 | 81 | { |
82 | 82 | Event::dispatch(new MethodCalled('wechat', __METHOD__, $order, null)); |
83 | 83 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | /** |
88 | 88 | * @throws InvalidParamsException |
89 | 89 | */ |
90 | - public function cancel(array $order): Collection|Rocket |
|
90 | + public function cancel(array $order): Collection | Rocket |
|
91 | 91 | { |
92 | 92 | throw new InvalidParamsException(Exception::PARAMS_METHOD_NOT_SUPPORTED, '参数异常: 微信不支持 cancel API'); |
93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @throws InvalidParamsException |
98 | 98 | * @throws ServiceNotFoundException |
99 | 99 | */ |
100 | - public function close(array $order): Collection|Rocket |
|
100 | + public function close(array $order): Collection | Rocket |
|
101 | 101 | { |
102 | 102 | Event::dispatch(new MethodCalled('wechat', __METHOD__, $order, null)); |
103 | 103 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @throws InvalidParamsException |
112 | 112 | * @throws ServiceNotFoundException |
113 | 113 | */ |
114 | - public function refund(array $order): Collection|Rocket |
|
114 | + public function refund(array $order): Collection | Rocket |
|
115 | 115 | { |
116 | 116 | Event::dispatch(new MethodCalled('wechat', __METHOD__, $order, null)); |
117 | 117 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @throws ContainerException |
123 | 123 | * @throws InvalidParamsException |
124 | 124 | */ |
125 | - public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection|Rocket |
|
125 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection | Rocket |
|
126 | 126 | { |
127 | 127 | $request = $this->getCallbackParams($contents); |
128 | 128 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ); |
153 | 153 | } |
154 | 154 | |
155 | - protected function getCallbackParams(null|array|ServerRequestInterface $contents = null): ServerRequestInterface |
|
155 | + protected function getCallbackParams(null | array | ServerRequestInterface $contents = null): ServerRequestInterface |
|
156 | 156 | { |
157 | 157 | if (is_array($contents) && isset($contents['body'], $contents['headers'])) { |
158 | 158 | return new ServerRequest('POST', 'http://localhost', $contents['headers'], $contents['body']); |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | return file_get_contents($key); |
49 | 49 | } |
50 | 50 | |
51 | - return "-----BEGIN RSA PRIVATE KEY-----\n". |
|
52 | - wordwrap($key, 64, "\n", true). |
|
51 | + return "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
52 | + wordwrap($key, 64, "\n", true) . |
|
53 | 53 | "\n-----END RSA PRIVATE KEY-----"; |
54 | 54 | } |
55 | 55 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | return $url; |
158 | 158 | } |
159 | 159 | |
160 | - return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
160 | + return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | function get_wechat_type_key(array $params): string |
178 | 178 | { |
179 | - $key = ($params['_type'] ?? 'mp').'_app_id'; |
|
179 | + $key = ($params['_type'] ?? 'mp') . '_app_id'; |
|
180 | 180 | |
181 | 181 | if ('app_app_id' === $key) { |
182 | 182 | $key = 'app_id'; |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | $buff = ''; |
220 | 220 | |
221 | 221 | foreach ($payload as $k => $v) { |
222 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
222 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
223 | 223 | } |
224 | 224 | |
225 | - $sign = md5($buff.'key='.$key); |
|
225 | + $sign = md5($buff . 'key=' . $key); |
|
226 | 226 | |
227 | 227 | return $upper ? strtoupper($sign) : $sign; |
228 | 228 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @throws InvalidSignException |
236 | 236 | * @throws ServiceNotFoundException |
237 | 237 | */ |
238 | -function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void |
|
238 | +function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void |
|
239 | 239 | { |
240 | 240 | if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) { |
241 | 241 | return; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $sign = $message->getHeaderLine('Wechatpay-Signature'); |
248 | 248 | $body = (string) $message->getBody(); |
249 | 249 | |
250 | - $content = $timestamp."\n".$random."\n".$body."\n"; |
|
250 | + $content = $timestamp . "\n" . $random . "\n" . $body . "\n"; |
|
251 | 251 | $public = get_provider_config('wechat', $params)['wechat_public_cert_path'][$wechatSerial] ?? null; |
252 | 252 | |
253 | 253 | if (empty($sign)) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | Pay::get(ConfigInterface::class)->set( |
335 | - 'wechat.'.get_tenant($params).'.wechat_public_cert_path', |
|
335 | + 'wechat.' . get_tenant($params) . '.wechat_public_cert_path', |
|
336 | 336 | ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []), |
337 | 337 | ); |
338 | 338 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) { |
366 | - file_put_contents($path.'/'.$serialNo.'.crt', $cert); |
|
366 | + file_put_contents($path . '/' . $serialNo . '.crt', $cert); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | /** |
396 | 396 | * @throws DecryptException |
397 | 397 | */ |
398 | -function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string |
|
398 | +function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string |
|
399 | 399 | { |
400 | 400 | $decrypted = openssl_decrypt( |
401 | 401 | substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE), |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null; |
457 | 457 | |
458 | 458 | if (empty($publicKey)) { |
459 | - throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -'.$serialNo); |
|
459 | + throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -' . $serialNo); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | return $publicKey; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | throw new InvalidConfigException(Exception::CONFIG_WECHAT_INVALID, '配置异常: 缺少微信配置 -- [mini_app_key_virtual_pay]'); |
472 | 472 | } |
473 | 473 | |
474 | - return hash_hmac('sha256', $url.'&'.$payload, $config['mini_app_key_virtual_pay']); |
|
474 | + return hash_hmac('sha256', $url . '&' . $payload, $config['mini_app_key_virtual_pay']); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | function get_wechat_miniprogram_user_sign(string $sessionKey, string $payload): string |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | return $url; |
533 | 533 | } |
534 | 534 | |
535 | - return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
535 | + return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -565,10 +565,10 @@ discard block |
||
565 | 565 | $buff = ''; |
566 | 566 | |
567 | 567 | foreach ($payload as $k => $v) { |
568 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
568 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
569 | 569 | } |
570 | 570 | |
571 | - return strtoupper(md5($buff.'key='.$key)); |
|
571 | + return strtoupper(md5($buff . 'key=' . $key)); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -647,5 +647,5 @@ discard block |
||
647 | 647 | return $url; |
648 | 648 | } |
649 | 649 | |
650 | - return Douyin::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url; |
|
650 | + return Douyin::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url; |
|
651 | 651 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | if (0 !== $destination->get('err_no')) { |
48 | - throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '抖音返回业务异常: '.$destination->get('err_tips'), $destination); |
|
48 | + throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '抖音返回业务异常: ' . $destination->get('err_tips'), $destination); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | public function getPlugins(array $params): array |
30 | 30 | { |
31 | - $method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
31 | + $method = Str::camel($params['_action'] ?? 'default') . 'Plugins'; |
|
32 | 32 | |
33 | 33 | if (method_exists($this, $method)) { |
34 | 34 | return $this->{$method}($params); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | return $this->combinePlugins(); |
41 | 41 | } |
42 | 42 | |
43 | - $method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
43 | + $method = Str::camel($params['_action'] ?? 'default') . 'Plugins'; |
|
44 | 44 | |
45 | 45 | if (method_exists($this, $method)) { |
46 | 46 | return $this->{$method}(); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | return $this->combinePlugins(); |
41 | 41 | } |
42 | 42 | |
43 | - $method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
43 | + $method = Str::camel($params['_action'] ?? 'default') . 'Plugins'; |
|
44 | 44 | |
45 | 45 | if (method_exists($this, $method)) { |
46 | 46 | return $this->{$method}(); |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @throws InvalidParamsException |
47 | 47 | * @throws ServiceNotFoundException |
48 | 48 | */ |
49 | - public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket |
|
49 | + public function __call(string $shortcut, array $params): null | Collection | MessageInterface | Rocket |
|
50 | 50 | { |
51 | - $plugin = '\Yansongda\Pay\Shortcut\Douyin\\'.Str::studly($shortcut).'Shortcut'; |
|
51 | + $plugin = '\Yansongda\Pay\Shortcut\Douyin\\' . Str::studly($shortcut) . 'Shortcut'; |
|
52 | 52 | |
53 | 53 | return Artful::shortcut($plugin, ...$params); |
54 | 54 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @throws ContainerException |
58 | 58 | * @throws InvalidParamsException |
59 | 59 | */ |
60 | - public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket |
|
60 | + public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket |
|
61 | 61 | { |
62 | 62 | return Artful::artful($plugins, $params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @throws InvalidParamsException |
68 | 68 | * @throws ServiceNotFoundException |
69 | 69 | */ |
70 | - public function query(array $order): Collection|Rocket |
|
70 | + public function query(array $order): Collection | Rocket |
|
71 | 71 | { |
72 | 72 | Event::dispatch(new MethodCalled('douyin', __METHOD__, $order, null)); |
73 | 73 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @throws InvalidParamsException |
79 | 79 | */ |
80 | - public function cancel(array $order): Collection|Rocket |
|
80 | + public function cancel(array $order): Collection | Rocket |
|
81 | 81 | { |
82 | 82 | throw new InvalidParamsException(Exception::PARAMS_METHOD_NOT_SUPPORTED, '参数异常: 抖音不支持 cancel API'); |
83 | 83 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * @throws InvalidParamsException |
87 | 87 | */ |
88 | - public function close(array $order): Collection|Rocket |
|
88 | + public function close(array $order): Collection | Rocket |
|
89 | 89 | { |
90 | 90 | throw new InvalidParamsException(Exception::PARAMS_METHOD_NOT_SUPPORTED, '参数异常: 抖音不支持 close API'); |
91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @throws InvalidParamsException |
96 | 96 | * @throws ServiceNotFoundException |
97 | 97 | */ |
98 | - public function refund(array $order): Collection|Rocket |
|
98 | + public function refund(array $order): Collection | Rocket |
|
99 | 99 | { |
100 | 100 | Event::dispatch(new MethodCalled('douyin', __METHOD__, $order, null)); |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @throws ContainerException |
107 | 107 | * @throws InvalidParamsException |
108 | 108 | */ |
109 | - public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection|Rocket |
|
109 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection | Rocket |
|
110 | 110 | { |
111 | 111 | $request = $this->getCallbackParams($contents); |
112 | 112 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - protected function getCallbackParams(null|array|ServerRequestInterface $contents = null): Collection |
|
136 | + protected function getCallbackParams(null | array | ServerRequestInterface $contents = null): Collection |
|
137 | 137 | { |
138 | 138 | if (is_array($contents)) { |
139 | 139 | return Collection::wrap($contents); |