@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * @throws ContainerException |
| 62 | 62 | */ |
| 63 | - public static function config(array $config = [], null|Closure|ContainerInterface $container = null): bool |
|
| 63 | + public static function config(array $config = [], null | Closure | ContainerInterface $container = null): bool |
|
| 64 | 64 | { |
| 65 | 65 | $result = Artful::config($config, $container); |
| 66 | 66 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | return Artful::get($service); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public static function setContainer(null|Closure|ContainerInterface $container): void |
|
| 91 | + public static function setContainer(null | Closure | ContainerInterface $container): void |
|
| 92 | 92 | { |
| 93 | 93 | Artful::setContainer($container); |
| 94 | 94 | } |
@@ -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, '配置异常: 解析 `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); |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | 'wxappid' => $config[$wechatTypeKey] ?? '', |
| 76 | 76 | 'mch_id' => $config['mch_id'] ?? '', |
| 77 | 77 | 'sub_mch_id' => $payload->get('sub_mch_id', $config['sub_mch_id'] ?? ''), |
| 78 | - 'msgappid' => $config['sub_'.$wechatTypeKey], |
|
| 78 | + 'msgappid' => $config['sub_' . $wechatTypeKey], |
|
| 79 | 79 | ]; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -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 | )); |
@@ -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 | )); |