@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $direction = Pay::get($direction); |
| 44 | 44 | |
| 45 | 45 | $direction = is_string($direction) ? Pay::get($direction) : $direction; |
| 46 | - } catch (ContainerException|ServiceNotFoundException) { |
|
| 46 | + } catch (ContainerException | ServiceNotFoundException) { |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | if (!$direction instanceof DirectionInterface) { |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | return file_get_contents($key); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return "-----BEGIN RSA PRIVATE KEY-----\n". |
|
| 79 | - wordwrap($key, 64, "\n", true). |
|
| 78 | + return "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
| 79 | + wordwrap($key, 64, "\n", true) . |
|
| 80 | 80 | "\n-----END RSA PRIVATE KEY-----"; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | $buff = ''; |
| 167 | 167 | |
| 168 | 168 | foreach ($payload as $k => $v) { |
| 169 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
| 169 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $sign = md5($buff.'key='.$key); |
|
| 172 | + $sign = md5($buff . 'key=' . $key); |
|
| 173 | 173 | |
| 174 | 174 | return $upper ? strtoupper($sign) : $sign; |
| 175 | 175 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @throws InvalidParamsException |
| 183 | 183 | * @throws InvalidSignException |
| 184 | 184 | */ |
| 185 | -function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void |
|
| 185 | +function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void |
|
| 186 | 186 | { |
| 187 | 187 | if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) { |
| 188 | 188 | return; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $sign = $message->getHeaderLine('Wechatpay-Signature'); |
| 195 | 195 | $body = (string) $message->getBody(); |
| 196 | 196 | |
| 197 | - $content = $timestamp."\n".$random."\n".$body."\n"; |
|
| 197 | + $content = $timestamp . "\n" . $random . "\n" . $body . "\n"; |
|
| 198 | 198 | $public = get_wechat_config($params)['wechat_public_cert_path'][$wechatSerial] ?? null; |
| 199 | 199 | |
| 200 | 200 | if (empty($sign)) { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $wechatConfig = get_wechat_config($params); |
| 248 | 248 | |
| 249 | 249 | Pay::get(ConfigInterface::class)->set( |
| 250 | - 'wechat.'.get_tenant($params).'.wechat_public_cert_path', |
|
| 250 | + 'wechat.' . get_tenant($params) . '.wechat_public_cert_path', |
|
| 251 | 251 | ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []), |
| 252 | 252 | ); |
| 253 | 253 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) { |
| 281 | - file_put_contents($path.'/'.$serialNo.'.crt', $cert); |
|
| 281 | + file_put_contents($path . '/' . $serialNo . '.crt', $cert); |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | /** |
| 313 | 313 | * @throws InvalidResponseException |
| 314 | 314 | */ |
| 315 | -function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string |
|
| 315 | +function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string |
|
| 316 | 316 | { |
| 317 | 317 | $decrypted = openssl_decrypt( |
| 318 | 318 | substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE), |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $result = $this->getCertSn($ssl['issuer'] ?? [], $ssl['serialNumber'] ?? ''); |
| 119 | 119 | |
| 120 | - Pay::get(ConfigInterface::class)->set('alipay.'.$tenant.'.app_public_cert_sn', $result); |
|
| 120 | + Pay::get(ConfigInterface::class)->set('alipay.' . $tenant . '.app_public_cert_sn', $result); |
|
| 121 | 121 | |
| 122 | 122 | return $result; |
| 123 | 123 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $ssl = openssl_x509_parse($cert.'-----END CERTIFICATE-----'); |
|
| 150 | + $ssl = openssl_x509_parse($cert . '-----END CERTIFICATE-----'); |
|
| 151 | 151 | |
| 152 | 152 | if (false === $ssl) { |
| 153 | 153 | throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, 'Invalid alipay_root_cert'); |
@@ -156,20 +156,20 @@ discard block |
||
| 156 | 156 | $detail = $this->formatCert($ssl); |
| 157 | 157 | |
| 158 | 158 | if ('sha1WithRSAEncryption' == $detail['signatureTypeLN'] || 'sha256WithRSAEncryption' == $detail['signatureTypeLN']) { |
| 159 | - $sn .= $this->getCertSn($detail['issuer'], $detail['serialNumber']).'_'; |
|
| 159 | + $sn .= $this->getCertSn($detail['issuer'], $detail['serialNumber']) . '_'; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $result = substr($sn, 0, -1); |
| 164 | 164 | |
| 165 | - Pay::get(ConfigInterface::class)->set('alipay.'.$tenant.'.alipay_root_cert_sn', $result); |
|
| 165 | + Pay::get(ConfigInterface::class)->set('alipay.' . $tenant . '.alipay_root_cert_sn', $result); |
|
| 166 | 166 | |
| 167 | 167 | return $result; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | protected function getCertSn(array $issuer, string $serialNumber): string |
| 171 | 171 | { |
| 172 | - return md5($this->array2string(array_reverse($issuer)).$serialNumber); |
|
| 172 | + return md5($this->array2string(array_reverse($issuer)) . $serialNumber); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | protected function array2string(array $array): string |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $string = []; |
| 178 | 178 | |
| 179 | 179 | foreach ($array as $key => $value) { |
| 180 | - $string[] = $key.'='.$value; |
|
| 180 | + $string[] = $key . '=' . $value; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return implode(',', $string); |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - return 'v3/combine-transactions/out-trade-no/'. |
|
| 24 | + return 'v3/combine-transactions/out-trade-no/' . |
|
| 25 | 25 | $payload->get('combine_out_trade_no', $payload->get('transaction_id')); |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -26,8 +26,8 @@ |
||
| 26 | 26 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return 'v3/combine-transactions/out-trade-no/'. |
|
| 30 | - $payload->get('combine_out_trade_no', $payload->get('out_trade_no')). |
|
| 29 | + return 'v3/combine-transactions/out-trade-no/' . |
|
| 30 | + $payload->get('combine_out_trade_no', $payload->get('out_trade_no')) . |
|
| 31 | 31 | '/close'; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | $payload = $rocket->getPayload(); |
| 27 | 27 | |
| 28 | 28 | if ($payload->has('transaction_id')) { |
| 29 | - return 'v3/pay/transactions/id/'. |
|
| 30 | - $payload->get('transaction_id'). |
|
| 31 | - '?mchid='.($config['mch_id'] ?? ''); |
|
| 29 | + return 'v3/pay/transactions/id/' . |
|
| 30 | + $payload->get('transaction_id') . |
|
| 31 | + '?mchid=' . ($config['mch_id'] ?? ''); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if ($payload->has('out_trade_no')) { |
| 35 | - return 'v3/pay/transactions/out-trade-no/'. |
|
| 36 | - $payload->get('out_trade_no'). |
|
| 37 | - '?mchid='.($config['mch_id'] ?? ''); |
|
| 35 | + return 'v3/pay/transactions/out-trade-no/' . |
|
| 36 | + $payload->get('out_trade_no') . |
|
| 37 | + '?mchid=' . ($config['mch_id'] ?? ''); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | $payload = $rocket->getPayload(); |
| 52 | 52 | |
| 53 | 53 | if ($payload->has('transaction_id')) { |
| 54 | - return 'v3/pay/partner/transactions/id/'. |
|
| 55 | - $payload->get('transaction_id'). |
|
| 56 | - '?sp_mchid='.($config['mch_id'] ?? ''). |
|
| 57 | - '&sub_mchid='.$payload->get('sub_mchid', $config['sub_mch_id'] ?? null); |
|
| 54 | + return 'v3/pay/partner/transactions/id/' . |
|
| 55 | + $payload->get('transaction_id') . |
|
| 56 | + '?sp_mchid=' . ($config['mch_id'] ?? '') . |
|
| 57 | + '&sub_mchid=' . $payload->get('sub_mchid', $config['sub_mch_id'] ?? null); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if ($payload->has('out_trade_no')) { |
| 61 | - return 'v3/pay/partner/transactions/out-trade-no/'. |
|
| 62 | - $payload->get('out_trade_no'). |
|
| 63 | - '?sp_mchid='.($config['mch_id'] ?? ''). |
|
| 64 | - '&sub_mchid='.$payload->get('sub_mchid', $config['sub_mch_id'] ?? null); |
|
| 61 | + return 'v3/pay/partner/transactions/out-trade-no/' . |
|
| 62 | + $payload->get('out_trade_no') . |
|
| 63 | + '?sp_mchid=' . ($config['mch_id'] ?? '') . |
|
| 64 | + '&sub_mchid=' . $payload->get('sub_mchid', $config['sub_mch_id'] ?? null); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return 'v3/refund/domestic/refunds/'.$payload->get('out_refund_no'); |
|
| 29 | + return 'v3/refund/domestic/refunds/' . $payload->get('out_refund_no'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $config = get_wechat_config($rocket->getParams()); |
| 39 | 39 | $url = parent::getPartnerUri($rocket); |
| 40 | 40 | |
| 41 | - return $url.'?sub_mchid='.$rocket->getPayload()->get('sub_mchid', $config['sub_mch_id'] ?? ''); |
|
| 41 | + return $url . '?sub_mchid=' . $rocket->getPayload()->get('sub_mchid', $config['sub_mch_id'] ?? ''); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | protected function getMethod(): string |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return 'v3/pay/transactions/out-trade-no/'. |
|
| 33 | - $payload->get('out_trade_no'). |
|
| 32 | + return 'v3/pay/transactions/out-trade-no/' . |
|
| 33 | + $payload->get('out_trade_no') . |
|
| 34 | 34 | '/close'; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return 'v3/pay/partner/transactions/out-trade-no/'. |
|
| 49 | - $payload->get('out_trade_no'). |
|
| 48 | + return 'v3/pay/partner/transactions/out-trade-no/' . |
|
| 49 | + $payload->get('out_trade_no') . |
|
| 50 | 50 | '/close'; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -35,6 +35,6 @@ |
||
| 35 | 35 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - return 'v3/transfer/bill-receipt/'.$payload->get('out_batch_no'); |
|
| 38 | + return 'v3/transfer/bill-receipt/' . $payload->get('out_batch_no'); |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - return 'v3/transfer/batches/batch-id/'. |
|
| 39 | - $payload->get('batch_id'). |
|
| 40 | - '/details/detail-id/'. |
|
| 38 | + return 'v3/transfer/batches/batch-id/' . |
|
| 39 | + $payload->get('batch_id') . |
|
| 40 | + '/details/detail-id/' . |
|
| 41 | 41 | $payload->get('detail_id'); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - return 'v3/partner-transfer/batches/batch-id/'. |
|
| 56 | - $payload->get('batch_id'). |
|
| 57 | - '/details/detail-id/'. |
|
| 55 | + return 'v3/partner-transfer/batches/batch-id/' . |
|
| 56 | + $payload->get('batch_id') . |
|
| 57 | + '/details/detail-id/' . |
|
| 58 | 58 | $payload->get('detail_id'); |
| 59 | 59 | } |
| 60 | 60 | } |