@@ -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 | /** |
@@ -28,14 +28,14 @@ |
||
28 | 28 | |
29 | 29 | $destination = $rocket->getDestination(); |
30 | 30 | $payload = $rocket->getPayload(); |
31 | - $resultKey = str_replace('.', '_', $payload->get('method')).'_response'; |
|
31 | + $resultKey = str_replace('.', '_', $payload->get('method')) . '_response'; |
|
32 | 32 | |
33 | 33 | if (should_do_http_request($rocket->getDirection()) && $destination instanceof Collection) { |
34 | 34 | $sign = $destination->get('sign', ''); |
35 | 35 | $response = $destination->get($resultKey, $destination->all()); |
36 | 36 | |
37 | 37 | if (empty($sign) && '10000' !== ($response['code'] ?? 'null')) { |
38 | - throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '支付宝网关响应异常: '.($response['sub_msg'] ?? $response['msg'] ?? '未知错误,请查看支付宝原始响应'), $rocket->getDestination()); |
|
38 | + throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '支付宝网关响应异常: ' . ($response['sub_msg'] ?? $response['msg'] ?? '未知错误,请查看支付宝原始响应'), $rocket->getDestination()); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $rocket->setDestination(new Collection(array_merge( |
@@ -50,8 +50,8 @@ |
||
50 | 50 | ->setPayload(array_merge( |
51 | 51 | [ |
52 | 52 | '_method' => 'POST', |
53 | - '_url' => 'v3/pay/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
54 | - '_service_url' => 'v3/pay/partner/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
53 | + '_url' => 'v3/pay/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
54 | + '_service_url' => 'v3/pay/partner/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
55 | 55 | ], |
56 | 56 | $data ?? $this->normal($config) |
57 | 57 | )); |
@@ -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 |
|
59 | + public function __call(string $shortcut, array $params): null | Collection | MessageInterface |
|
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']); |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @throws InvalidParamsException |
53 | 53 | * @throws ServiceNotFoundException |
54 | 54 | */ |
55 | - public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket |
|
55 | + public function __call(string $shortcut, array $params): null | Collection | MessageInterface | Rocket |
|
56 | 56 | { |
57 | - $plugin = '\Yansongda\Pay\Shortcut\Alipay\\'.Str::studly($shortcut).'Shortcut'; |
|
57 | + $plugin = '\Yansongda\Pay\Shortcut\Alipay\\' . Str::studly($shortcut) . 'Shortcut'; |
|
58 | 58 | |
59 | 59 | return Artful::shortcut($plugin, ...$params); |
60 | 60 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @throws ContainerException |
64 | 64 | * @throws InvalidParamsException |
65 | 65 | */ |
66 | - public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket |
|
66 | + public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket |
|
67 | 67 | { |
68 | 68 | return Artful::artful($plugins, $params); |
69 | 69 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @throws InvalidParamsException |
74 | 74 | * @throws ServiceNotFoundException |
75 | 75 | */ |
76 | - public function query(array $order): Collection|Rocket |
|
76 | + public function query(array $order): Collection | Rocket |
|
77 | 77 | { |
78 | 78 | Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null)); |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @throws InvalidParamsException |
86 | 86 | * @throws ServiceNotFoundException |
87 | 87 | */ |
88 | - public function cancel(array $order): Collection|Rocket |
|
88 | + public function cancel(array $order): Collection | Rocket |
|
89 | 89 | { |
90 | 90 | Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null)); |
91 | 91 | |
@@ -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('alipay', __METHOD__, $order, null)); |
103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @throws InvalidParamsException |
110 | 110 | * @throws ServiceNotFoundException |
111 | 111 | */ |
112 | - public function refund(array $order): Collection|Rocket |
|
112 | + public function refund(array $order): Collection | Rocket |
|
113 | 113 | { |
114 | 114 | Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null)); |
115 | 115 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @throws ContainerException |
121 | 121 | * @throws InvalidParamsException |
122 | 122 | */ |
123 | - public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection |
|
123 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection |
|
124 | 124 | { |
125 | 125 | $request = $this->getCallbackParams($contents); |
126 | 126 | |
@@ -143,15 +143,14 @@ discard block |
||
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | - protected function getCallbackParams(null|array|ServerRequestInterface $contents = null): Collection |
|
146 | + protected function getCallbackParams(null | array | ServerRequestInterface $contents = null): Collection |
|
147 | 147 | { |
148 | 148 | if (is_array($contents)) { |
149 | 149 | return Collection::wrap($contents); |
150 | 150 | } |
151 | 151 | |
152 | 152 | if ($contents instanceof ServerRequestInterface) { |
153 | - return Collection::wrap('GET' === $contents->getMethod() ? $contents->getQueryParams() : |
|
154 | - $contents->getParsedBody()); |
|
153 | + return Collection::wrap('GET' === $contents->getMethod() ? $contents->getQueryParams() : $contents->getParsedBody()); |
|
155 | 154 | } |
156 | 155 | |
157 | 156 | $request = ServerRequest::fromGlobals(); |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @throws InvalidParamsException |
50 | 50 | * @throws ServiceNotFoundException |
51 | 51 | */ |
52 | - public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket |
|
52 | + public function __call(string $shortcut, array $params): null | Collection | MessageInterface | Rocket |
|
53 | 53 | { |
54 | - $plugin = '\Yansongda\Pay\Shortcut\Unipay\\'.Str::studly($shortcut).'Shortcut'; |
|
54 | + $plugin = '\Yansongda\Pay\Shortcut\Unipay\\' . Str::studly($shortcut) . 'Shortcut'; |
|
55 | 55 | |
56 | 56 | return Artful::shortcut($plugin, ...$params); |
57 | 57 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @throws ContainerException |
61 | 61 | * @throws InvalidParamsException |
62 | 62 | */ |
63 | - public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket |
|
63 | + public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket |
|
64 | 64 | { |
65 | 65 | return Artful::artful($plugins, $params); |
66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @throws InvalidParamsException |
71 | 71 | * @throws ServiceNotFoundException |
72 | 72 | */ |
73 | - public function query(array $order): Collection|Rocket |
|
73 | + public function query(array $order): Collection | Rocket |
|
74 | 74 | { |
75 | 75 | Event::dispatch(new MethodCalled('unipay', __METHOD__, $order, null)); |
76 | 76 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @throws InvalidParamsException |
83 | 83 | * @throws ServiceNotFoundException |
84 | 84 | */ |
85 | - public function cancel(array $order): Collection|Rocket |
|
85 | + public function cancel(array $order): Collection | Rocket |
|
86 | 86 | { |
87 | 87 | Event::dispatch(new MethodCalled('unipay', __METHOD__, $order, null)); |
88 | 88 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @throws InvalidParamsException |
94 | 94 | */ |
95 | - public function close(array $order): Collection|Rocket |
|
95 | + public function close(array $order): Collection | Rocket |
|
96 | 96 | { |
97 | 97 | throw new InvalidParamsException(Exception::PARAMS_METHOD_NOT_SUPPORTED, '参数异常: 银联不支持 close API'); |
98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @throws InvalidParamsException |
103 | 103 | * @throws ServiceNotFoundException |
104 | 104 | */ |
105 | - public function refund(array $order): Collection|Rocket |
|
105 | + public function refund(array $order): Collection | Rocket |
|
106 | 106 | { |
107 | 107 | Event::dispatch(new MethodCalled('unipay', __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|Rocket |
|
116 | + public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection | Rocket |
|
117 | 117 | { |
118 | 118 | $request = $this->getCallbackParams($contents); |
119 | 119 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ); |
140 | 140 | } |
141 | 141 | |
142 | - protected function getCallbackParams(null|array|ServerRequestInterface $contents = null): Collection |
|
142 | + protected function getCallbackParams(null | array | ServerRequestInterface $contents = null): Collection |
|
143 | 143 | { |
144 | 144 | if (is_array($contents)) { |
145 | 145 | return Collection::wrap($contents); |
@@ -49,8 +49,8 @@ |
||
49 | 49 | $rocket->setDirection(OriginResponseDirection::class) |
50 | 50 | ->setPayload(array_merge( |
51 | 51 | [ |
52 | - '_url' => 'v3/pay/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
53 | - '_service_url' => 'v3/pay/partner/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
52 | + '_url' => 'v3/pay/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
53 | + '_service_url' => 'v3/pay/partner/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
54 | 54 | '_method' => 'POST', |
55 | 55 | ], |
56 | 56 | $data ?? $this->normal($config) |
@@ -50,8 +50,8 @@ |
||
50 | 50 | ->setPayload(array_merge( |
51 | 51 | [ |
52 | 52 | '_method' => 'POST', |
53 | - '_url' => 'v3/pay/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
54 | - '_service_url' => 'v3/pay/partner/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
53 | + '_url' => 'v3/pay/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
54 | + '_service_url' => 'v3/pay/partner/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
55 | 55 | ], |
56 | 56 | $data ?? $this->normal($config) |
57 | 57 | )); |
@@ -50,8 +50,8 @@ |
||
50 | 50 | ->setPayload(array_merge( |
51 | 51 | [ |
52 | 52 | '_method' => 'POST', |
53 | - '_url' => 'v3/pay/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
54 | - '_service_url' => 'v3/pay/partner/transactions/out-trade-no/'.$outTradeNo.'/close', |
|
53 | + '_url' => 'v3/pay/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
54 | + '_service_url' => 'v3/pay/partner/transactions/out-trade-no/' . $outTradeNo . '/close', |
|
55 | 55 | ], |
56 | 56 | $data ?? $this->normal($config) |
57 | 57 | )); |