@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | public function pay(array $params) |
| 35 | 35 | { |
| 36 | 36 | $method = 'alipay.trade.pay'; |
| 37 | - $params['scene'] = $params['scene'] ?? 'bar_code'; |
|
| 37 | + $params[ 'scene' ] = $params[ 'scene' ] ?? 'bar_code'; |
|
| 38 | 38 | $this->app->setEndpointConfig($method, [ |
| 39 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
| 39 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
| 40 | 40 | ]); |
| 41 | 41 | |
| 42 | 42 | return $this->request($method, [ |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $method = 'alipay.trade.create'; |
| 61 | 61 | $this->app->setEndpointConfig($method, [ |
| 62 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
| 62 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
| 63 | 63 | ]); |
| 64 | 64 | |
| 65 | 65 | return $this->request($method, [ |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $method = 'alipay.trade.precreate'; |
| 84 | 84 | $this->app->setEndpointConfig($method, [ |
| 85 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
| 85 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
| 86 | 86 | ]); |
| 87 | 87 | |
| 88 | 88 | return $this->request($method, [ |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | 'trade_no' => $tradeNo, |
| 112 | 112 | 'out_trade_no' => $outTradeNo, |
| 113 | 113 | 'operator_id' => $operatorId, |
| 114 | - ], function ($value) { |
|
| 114 | + ], function($value) { |
|
| 115 | 115 | return !($this->checkEmpty($value)); |
| 116 | 116 | }); |
| 117 | 117 | $this->app->setEndpointConfig($method, [ |
| 118 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
| 118 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
| 119 | 119 | ]); |
| 120 | 120 | |
| 121 | 121 | return $this->request($method, [ |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException |
| 138 | 138 | * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException |
| 139 | 139 | */ |
| 140 | - public function refund(string $tradeNo, $amount, string $outTradeNo = null, array $params = []) |
|
| 140 | + public function refund(string $tradeNo, $amount, string $outTradeNo = null, array $params = [ ]) |
|
| 141 | 141 | { |
| 142 | 142 | $params = array_merge(array_filter([ |
| 143 | 143 | 'trade_no' => $tradeNo, |
| 144 | 144 | 'out_trade_no' => $outTradeNo, |
| 145 | 145 | 'refund_amount' => $amount, |
| 146 | - ], function ($value) { |
|
| 146 | + ], function($value) { |
|
| 147 | 147 | return !($this->checkEmpty($value)); |
| 148 | 148 | }), $params); |
| 149 | 149 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | 'trade_no' => $tradeNo, |
| 172 | 172 | 'out_trade_no' => $outTradeNo, |
| 173 | 173 | 'org_pid' => $orgPid, |
| 174 | - ], function ($value) { |
|
| 174 | + ], function($value) { |
|
| 175 | 175 | return !($this->checkEmpty($value)); |
| 176 | 176 | }); |
| 177 | 177 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $params = array_filter([ |
| 198 | 198 | 'trade_no' => $tradeNo, |
| 199 | 199 | 'out_trade_no' => $outTradeNo, |
| 200 | - ], function ($value) { |
|
| 200 | + ], function($value) { |
|
| 201 | 201 | return !($this->checkEmpty($value)); |
| 202 | 202 | }); |
| 203 | 203 | |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function orderSettle(string $outRequestNo, string $tradeNo, array $royaltyParameters, string $operatorId = null) |
| 224 | 224 | { |
| 225 | - $royalty = []; |
|
| 225 | + $royalty = [ ]; |
|
| 226 | 226 | if (count($royaltyParameters) === count($royaltyParameters, COUNT_RECURSIVE)) { |
| 227 | - $royalty[0] = $royaltyParameters; |
|
| 227 | + $royalty[ 0 ] = $royaltyParameters; |
|
| 228 | 228 | } else { |
| 229 | 229 | $royalty = $royaltyParameters; |
| 230 | 230 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'trade_no' => $tradeNo, |
| 234 | 234 | 'royalty_parameters' => $royalty, |
| 235 | 235 | 'operator_id' => $operatorId, |
| 236 | - ], function ($value) { |
|
| 236 | + ], function($value) { |
|
| 237 | 237 | return !($this->checkEmpty($value)); |
| 238 | 238 | }); |
| 239 | 239 | |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | 'out_request_no' => $outRequestNo, |
| 265 | 265 | 'orig_request_no' => $origRequestNo, |
| 266 | 266 | 'biz_type' => $bizType, |
| 267 | - ], function ($value) { |
|
| 267 | + ], function($value) { |
|
| 268 | 268 | return !($this->checkEmpty($value)); |
| 269 | 269 | }); |
| 270 | 270 | |
| 271 | 271 | if (!($this->checkEmpty($orderBizInfo))) { |
| 272 | - $params['order_biz_info'] = json_encode(['status' => $orderBizInfo]); |
|
| 272 | + $params[ 'order_biz_info' ] = json_encode([ 'status' => $orderBizInfo ]); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | return $this->request('alipay.trade.orderinfo.sync', [ |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $this->app = $app; |
| 47 | 47 | |
| 48 | - $this->setHttpClient($this->app['http_client']); |
|
| 48 | + $this->setHttpClient($this->app[ 'http_client' ]); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException |
| 64 | 64 | * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException |
| 65 | 65 | */ |
| 66 | - public function request($endpoint, $params = [], $method = 'POST', array $options = [], $returnResponse = false) |
|
| 66 | + public function request($endpoint, $params = [ ], $method = 'POST', array $options = [ ], $returnResponse = false) |
|
| 67 | 67 | { |
| 68 | 68 | // Get api system parameters |
| 69 | 69 | $sysParams = $this->app->apiCommonConfig($endpoint); |
| 70 | 70 | // Filter system parameters |
| 71 | - $sysParams = array_filter($sysParams, function ($value) { |
|
| 71 | + $sysParams = array_filter($sysParams, function($value) { |
|
| 72 | 72 | return !($this->checkEmpty($value)); |
| 73 | 73 | }); |
| 74 | 74 | $params = $this->json($params); |
| 75 | 75 | // Set the signature |
| 76 | - $sysParams['sign'] = $this->generateSign(array_merge($sysParams, $params), $sysParams['sign_type']); |
|
| 76 | + $sysParams[ 'sign' ] = $this->generateSign(array_merge($sysParams, $params), $sysParams[ 'sign_type' ]); |
|
| 77 | 77 | // Set log middleware to record data, Log request and response data to the log file info level |
| 78 | 78 | $this->pushMiddleware($this->logMiddleware(), 'log'); |
| 79 | 79 | // Set http parameter options |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | 'form_params' => $params, |
| 82 | 82 | 'headers' => [ |
| 83 | 83 | 'content-type' => 'application/x-www-form-urlencoded', |
| 84 | - 'charset' => $sysParams['charset'], |
|
| 84 | + 'charset' => $sysParams[ 'charset' ], |
|
| 85 | 85 | ], |
| 86 | 86 | ], $options); |
| 87 | 87 | |
| 88 | - $response = $this->performRequest($method, '?'.http_build_query($sysParams), $options); |
|
| 88 | + $response = $this->performRequest($method, '?' . http_build_query($sysParams), $options); |
|
| 89 | 89 | |
| 90 | - $arrayBody = \GuzzleHttp\json_decode((string)$response->getBody(), true, 512, JSON_BIGINT_AS_STRING); |
|
| 90 | + $arrayBody = \GuzzleHttp\json_decode((string) $response->getBody(), true, 512, JSON_BIGINT_AS_STRING); |
|
| 91 | 91 | $context = \GuzzleHttp\json_encode($this->parserSignSource($arrayBody, $endpoint), JSON_UNESCAPED_UNICODE); |
| 92 | 92 | |
| 93 | 93 | // Verify Response Signature |
| 94 | - $this->checkResponseSign($context, $arrayBody['sign'] ?? null); |
|
| 94 | + $this->checkResponseSign($context, $arrayBody[ 'sign' ] ?? null); |
|
| 95 | 95 | |
| 96 | 96 | return $returnResponse ? $response : $this->handleResponse($response, $context); |
| 97 | 97 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | public function handleResponse(ResponseInterface $response, string $context = null) |
| 110 | 110 | { |
| 111 | 111 | $is_build = true; |
| 112 | - if ($this->app['config']->get('handle_response', true) && !is_null($context)) { |
|
| 112 | + if ($this->app[ 'config' ]->get('handle_response', true) && !is_null($context)) { |
|
| 113 | 113 | $response = new Response( |
| 114 | 114 | $response->getStatusCode(), |
| 115 | 115 | $response->getHeaders(), |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $is_build = false; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return $this->castResponseToType($response, $this->app['config']->get('response_type', 'array'), $is_build); |
|
| 123 | + return $this->castResponseToType($response, $this->app[ 'config' ]->get('response_type', 'array'), $is_build); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function logMiddleware() |
| 132 | 132 | { |
| 133 | - $formatter = new MessageFormatter($this->app['config']['http.log_template'] ?? MessageFormatter::DEBUG); |
|
| 133 | + $formatter = new MessageFormatter($this->app[ 'config' ][ 'http.log_template' ] ?? MessageFormatter::DEBUG); |
|
| 134 | 134 | |
| 135 | - return Middleware::log($this->app['logger']->getLogger(), $formatter); |
|
| 135 | + return Middleware::log($this->app[ 'logger' ]->getLogger(), $formatter); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | protected function json(array $data): array |
| 146 | 146 | { |
| 147 | - $array = []; |
|
| 148 | - if (isset($data['biz_content']) && is_array($data['biz_content'])) { |
|
| 149 | - $array['biz_content'] = \GuzzleHttp\json_encode($data['biz_content'], JSON_UNESCAPED_UNICODE); |
|
| 147 | + $array = [ ]; |
|
| 148 | + if (isset($data[ 'biz_content' ]) && is_array($data[ 'biz_content' ])) { |
|
| 149 | + $array[ 'biz_content' ] = \GuzzleHttp\json_encode($data[ 'biz_content' ], JSON_UNESCAPED_UNICODE); |
|
| 150 | 150 | } else { |
| 151 | 151 | return $data; |
| 152 | 152 | } |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @var array |
| 52 | 52 | */ |
| 53 | - protected $providers = []; |
|
| 53 | + protected $providers = [ ]; |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @var array |
| 57 | 57 | */ |
| 58 | - protected $userConfig = []; |
|
| 58 | + protected $userConfig = [ ]; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @var array |
| 62 | 62 | */ |
| 63 | - protected $defaultConfig = []; |
|
| 63 | + protected $defaultConfig = [ ]; |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Application constructor. |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function __construct(array $config) |
| 71 | 71 | { |
| 72 | - parent::__construct(['app_client_providers' => $this->providers]); |
|
| 72 | + parent::__construct([ 'app_client_providers' => $this->providers ]); |
|
| 73 | 73 | $this->init($config); |
| 74 | 74 | $this->registerProviders($this->getProviders()); |
| 75 | 75 | } |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function __get($name) |
| 87 | 87 | { |
| 88 | - if (isset($this[$name])) { |
|
| 89 | - return $this[$name]; |
|
| 88 | + if (isset($this[ $name ])) { |
|
| 89 | + return $this[ $name ]; |
|
| 90 | 90 | } |
| 91 | 91 | throw new RuntimeException(sprintf('Identifier "%s" is not defined', $name)); |
| 92 | 92 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $this->config->set('api_method', $endpoint); |
| 133 | 133 | |
| 134 | 134 | return array_merge([ |
| 135 | - 'app_id' => $this->config['sys_params.app_id'], |
|
| 135 | + 'app_id' => $this->config[ 'sys_params.app_id' ], |
|
| 136 | 136 | 'method' => $endpoint, |
| 137 | 137 | 'format' => 'JSON', |
| 138 | 138 | 'charset' => $this->config->get('sys_params.charset', 'utf-8'), |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | 'timestamp' => date('Y-m-d H:i:s'), |
| 142 | 142 | 'version' => '1.0', |
| 143 | 143 | 'app_auth_token' => $this->config->get('sys_params.app_auth_token', ''), |
| 144 | - ], $this->config->get($endpoint.'config', [])); |
|
| 144 | + ], $this->config->get($endpoint . 'config', [ ])); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function setEndpointConfig(string $endpoint, array $config) |
| 156 | 156 | { |
| 157 | - $this->config->set($endpoint.'config', $config); |
|
| 157 | + $this->config->set($endpoint . 'config', $config); |
|
| 158 | 158 | |
| 159 | 159 | return $this; |
| 160 | 160 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function getEnv() |
| 182 | 182 | { |
| 183 | - return isset($this->userConfig['env']) ? $this->userConfig['env'] : self::NORMAL_ENV; |
|
| 183 | + return isset($this->userConfig[ 'env' ]) ? $this->userConfig[ 'env' ] : self::NORMAL_ENV; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function getGateway() |
| 192 | 192 | { |
| 193 | - if (isset($this->gateway[$this->getEnv()])) { |
|
| 194 | - return $this->gateway[$this->getEnv()]; |
|
| 193 | + if (isset($this->gateway[ $this->getEnv() ])) { |
|
| 194 | + return $this->gateway[ $this->getEnv() ]; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - return $this->gateway[self::NORMAL_ENV]; |
|
| 197 | + return $this->gateway[ self::NORMAL_ENV ]; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |