@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | foreach ($params as $k => $v) { |
53 | 53 | if (false === $this->checkEmpty($v) && "@" !== substr($v, 0, 1)) { |
54 | 54 | if ($i === 0) { |
55 | - $stringToBeSigned .= "$k"."="."$v"; |
|
55 | + $stringToBeSigned .= "$k" . "=" . "$v"; |
|
56 | 56 | } else { |
57 | - $stringToBeSigned .= "&"."$k"."="."$v"; |
|
57 | + $stringToBeSigned .= "&" . "$k" . "=" . "$v"; |
|
58 | 58 | } |
59 | 59 | $i++; |
60 | 60 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | foreach ($params as $k => $v) { |
82 | 82 | if (false === $this->checkEmpty($v) && "@" !== substr($v, 0, 1)) { |
83 | 83 | if ($i === 0) { |
84 | - $stringToBeSigned .= "$k"."=".urlencode($v); |
|
84 | + $stringToBeSigned .= "$k" . "=" . urlencode($v); |
|
85 | 85 | } else { |
86 | - $stringToBeSigned .= "&"."$k"."=".urlencode($v); |
|
86 | + $stringToBeSigned .= "&" . "$k" . "=" . urlencode($v); |
|
87 | 87 | } |
88 | 88 | $i++; |
89 | 89 | } |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function sign($data, $signType = "RSA2") |
108 | 108 | { |
109 | - $rsaPrivateKeyFilePath = $this->app['config']->get('private_key_path'); |
|
109 | + $rsaPrivateKeyFilePath = $this->app[ 'config' ]->get('private_key_path'); |
|
110 | 110 | if ($this->checkEmpty($rsaPrivateKeyFilePath)) { |
111 | - $priKey = $this->app['config']['private_key']; |
|
112 | - $priKey = "-----BEGIN RSA PRIVATE KEY-----\n". |
|
113 | - wordwrap($priKey, 64, "\n", true). |
|
111 | + $priKey = $this->app[ 'config' ][ 'private_key' ]; |
|
112 | + $priKey = "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
113 | + wordwrap($priKey, 64, "\n", true) . |
|
114 | 114 | "\n-----END RSA PRIVATE KEY-----"; |
115 | 115 | } else { |
116 | 116 | $priKey = file_get_contents($rsaPrivateKeyFilePath); |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | { |
174 | 174 | $response_suffix = '_response'; |
175 | 175 | $error_respones = 'error_response'; |
176 | - $apiMethod = $this->app['config']['api_method'] ?? $apiMethod; |
|
177 | - $rootNodeName = str_replace(".", "_", $apiMethod).$response_suffix; |
|
176 | + $apiMethod = $this->app[ 'config' ][ 'api_method' ] ?? $apiMethod; |
|
177 | + $rootNodeName = str_replace(".", "_", $apiMethod) . $response_suffix; |
|
178 | 178 | |
179 | - if (isset($response[$rootNodeName])) { |
|
180 | - return $response[$rootNodeName]; |
|
181 | - } elseif (isset($response[$error_respones])) { |
|
182 | - return $response[$error_respones]; |
|
179 | + if (isset($response[ $rootNodeName ])) { |
|
180 | + return $response[ $rootNodeName ]; |
|
181 | + } elseif (isset($response[ $error_respones ])) { |
|
182 | + return $response[ $error_respones ]; |
|
183 | 183 | } else { |
184 | 184 | return $response; |
185 | 185 | } |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function verify(string $data, $sign, $signType = 'RSA2') |
200 | 200 | { |
201 | - $alipayPublicKeyPath = $this->app['config']->get('alipay_public_Key_path'); |
|
201 | + $alipayPublicKeyPath = $this->app[ 'config' ]->get('alipay_public_Key_path'); |
|
202 | 202 | if ($this->checkEmpty($alipayPublicKeyPath)) { |
203 | - $pubKey = $this->app['config']->get('alipay_public_Key'); |
|
204 | - $pubKey = "-----BEGIN PUBLIC KEY-----\n". |
|
205 | - wordwrap($pubKey, 64, "\n", true). |
|
203 | + $pubKey = $this->app[ 'config' ]->get('alipay_public_Key'); |
|
204 | + $pubKey = "-----BEGIN PUBLIC KEY-----\n" . |
|
205 | + wordwrap($pubKey, 64, "\n", true) . |
|
206 | 206 | "\n-----END PUBLIC KEY-----"; |
207 | 207 | } else { |
208 | 208 | // Read public key file |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $result = $this->verify( |
247 | 247 | $content, |
248 | 248 | $sign, |
249 | - $this->app['config']->get('sign_type', 'RSA2') |
|
249 | + $this->app[ 'config' ]->get('sign_type', 'RSA2') |
|
250 | 250 | ); |
251 | 251 | } else { |
252 | 252 | throw new InvalidSignException('check sign Fail! The reason : sign data is Empty', 0, $content); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | if (!$result) { |
256 | 256 | throw new InvalidSignException(sprintf( |
257 | 257 | '"%s" method responds to parameter validation signature error', |
258 | - $this->app['config']['api_method'] |
|
258 | + $this->app[ 'config' ][ 'api_method' ] |
|
259 | 259 | )); |
260 | 260 | } |
261 | 261 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException |
66 | 66 | */ |
67 | - public function page(string $tradeNo, $amount, string $outRequestNo, string $outTradeNo = null, array $params = [], string $httpMethod = 'POST') |
|
67 | + public function page(string $tradeNo, $amount, string $outRequestNo, string $outTradeNo = null, array $params = [ ], string $httpMethod = 'POST') |
|
68 | 68 | { |
69 | 69 | $method = 'alipay.trade.page.refund'; |
70 | 70 | $params = array_merge(array_filter([ |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return !($this->checkEmpty($value)); |
77 | 77 | }), $params); |
78 | 78 | $this->app->setEndpointConfig($method, [ |
79 | - 'return_url' => $this->app['config']->get('return_url'), |
|
79 | + 'return_url' => $this->app[ 'config' ]->get('return_url'), |
|
80 | 80 | ]); |
81 | 81 | |
82 | 82 | return $this->pageExecute($method, [ |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException |
32 | 32 | */ |
33 | - public function sdkExecute(string $endpoint, array $params = []) |
|
33 | + public function sdkExecute(string $endpoint, array $params = [ ]) |
|
34 | 34 | { |
35 | 35 | // Get api system parameters |
36 | 36 | $sysParams = $this->app->apiCommonConfig($endpoint); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | }); |
41 | 41 | $params = array_merge($sysParams, $this->json($params)); |
42 | 42 | // Set the signature |
43 | - $params['sign'] = $this->generateSign($params, $sysParams['sign_type']); |
|
43 | + $params[ 'sign' ] = $this->generateSign($params, $sysParams[ 'sign_type' ]); |
|
44 | 44 | |
45 | 45 | ksort($params); |
46 | 46 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException |
60 | 60 | */ |
61 | - public function pageExecute(string $endpoint, array $params = [], string $httpMethod = "POST") |
|
61 | + public function pageExecute(string $endpoint, array $params = [ ], string $httpMethod = "POST") |
|
62 | 62 | { |
63 | 63 | |
64 | 64 | // Get api system parameters |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | }); |
70 | 70 | $params = array_merge($sysParams, $this->json($params)); |
71 | 71 | // Set the signature |
72 | - $params['sign'] = $this->generateSign($params, $sysParams['sign_type']); |
|
72 | + $params[ 'sign' ] = $this->generateSign($params, $sysParams[ 'sign_type' ]); |
|
73 | 73 | |
74 | 74 | if ("GET" === strtoupper($httpMethod)) { |
75 | 75 | // value urlencode |
76 | 76 | $preString = $this->getSignContentUrlencode($params); |
77 | 77 | // Stitching GET request string |
78 | - $requestUrl = $this->app->getGateway()."?".$preString; |
|
78 | + $requestUrl = $this->app->getGateway() . "?" . $preString; |
|
79 | 79 | |
80 | 80 | return $requestUrl; |
81 | 81 | } else { |
@@ -93,21 +93,21 @@ discard block |
||
93 | 93 | */ |
94 | 94 | protected function buildRequestForm(array $paraTemp) |
95 | 95 | { |
96 | - $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='". |
|
97 | - $this->app->getGateway()."?charset=".trim($paraTemp['charset']). |
|
96 | + $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . |
|
97 | + $this->app->getGateway() . "?charset=" . trim($paraTemp[ 'charset' ]) . |
|
98 | 98 | "' method='POST'>"; |
99 | 99 | |
100 | 100 | foreach ($paraTemp as $key => $val) { |
101 | 101 | if (false === $this->checkEmpty($val)) { |
102 | 102 | $val = str_replace("'", "'", $val); |
103 | - $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>"; |
|
103 | + $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Submit button control please do not include the name attribute |
108 | - $sHtml = $sHtml."<input type='submit' value='ok' style='display:none;''></form>"; |
|
108 | + $sHtml = $sHtml . "<input type='submit' value='ok' style='display:none;''></form>"; |
|
109 | 109 | |
110 | - $sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>"; |
|
110 | + $sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>"; |
|
111 | 111 | |
112 | 112 | return $sHtml; |
113 | 113 | } |
@@ -29,8 +29,8 @@ |
||
29 | 29 | */ |
30 | 30 | public function register(Container $pimple) |
31 | 31 | { |
32 | - $pimple['http_client'] = function ($app) { |
|
33 | - return new Client($app['config']->get('http', [])); |
|
32 | + $pimple[ 'http_client' ] = function ($app) { |
|
33 | + return new Client($app[ 'config' ]->get('http', [ ])); |
|
34 | 34 | }; |
35 | 35 | } |
36 | 36 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | public function register(Container $pimple) |
31 | 31 | { |
32 | - $pimple['request'] = function () { |
|
32 | + $pimple[ 'request' ] = function () { |
|
33 | 33 | return Request::createFromGlobals(); |
34 | 34 | }; |
35 | 35 | } |
@@ -28,8 +28,8 @@ |
||
28 | 28 | */ |
29 | 29 | public function register(Container $pimple) |
30 | 30 | { |
31 | - foreach ($pimple['app_client_providers'] as $key => $value) { |
|
32 | - $pimple[$key] = function ($app) use ($value) { |
|
31 | + foreach ($pimple[ 'app_client_providers' ] as $key => $value) { |
|
32 | + $pimple[ $key ] = function ($app) use ($value) { |
|
33 | 33 | return new $value($app); |
34 | 34 | }; |
35 | 35 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | public function register(Container $pimple) |
32 | 32 | { |
33 | - $pimple['config'] = function (App $app) { |
|
33 | + $pimple[ 'config' ] = function (App $app) { |
|
34 | 34 | return new Config($app->getConfig()); |
35 | 35 | }; |
36 | 36 | } |
@@ -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,7 +63,7 @@ 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); |
@@ -73,7 +73,7 @@ discard block |
||
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,8 +109,8 @@ discard block |
||
109 | 109 | public function handleResponse(ResponseInterface $response, string $context = null) |
110 | 110 | { |
111 | 111 | $is_build = true; |
112 | - $response_type = $this->app['config']->get('response_type', 'array'); |
|
113 | - $handle_response = $this->app['config']->get('handle_response', true); |
|
112 | + $response_type = $this->app[ 'config' ]->get('response_type', 'array'); |
|
113 | + $handle_response = $this->app[ 'config' ]->get('handle_response', true); |
|
114 | 114 | if ($handle_response && !is_null($context) && $response_type !== 'raw') { |
115 | 115 | $response = new Response( |
116 | 116 | $response->getStatusCode(), |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function logMiddleware() |
134 | 134 | { |
135 | - $formatter = new MessageFormatter($this->app['config']['http.log_template'] ?? MessageFormatter::DEBUG); |
|
135 | + $formatter = new MessageFormatter($this->app[ 'config' ][ 'http.log_template' ] ?? MessageFormatter::DEBUG); |
|
136 | 136 | |
137 | - return Middleware::log($this->app['logger']->getLogger(), $formatter); |
|
137 | + return Middleware::log($this->app[ 'logger' ]->getLogger(), $formatter); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function json(array $data): array |
148 | 148 | { |
149 | - $array = []; |
|
150 | - if (isset($data['biz_content']) && is_array($data['biz_content'])) { |
|
151 | - $array['biz_content'] = \GuzzleHttp\json_encode($data['biz_content'], JSON_UNESCAPED_UNICODE); |
|
149 | + $array = [ ]; |
|
150 | + if (isset($data[ 'biz_content' ]) && is_array($data[ 'biz_content' ])) { |
|
151 | + $array[ 'biz_content' ] = \GuzzleHttp\json_encode($data[ 'biz_content' ], JSON_UNESCAPED_UNICODE); |
|
152 | 152 | } else { |
153 | 153 | return $data; |
154 | 154 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | 'product_code' => 'FACE_TO_FACE_PAYMENT', |
40 | 40 | ], $params); |
41 | 41 | $this->app->setEndpointConfig($method, [ |
42 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
42 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
43 | 43 | ]); |
44 | 44 | |
45 | 45 | return $this->request($method, [ |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $method = 'alipay.trade.create'; |
64 | 64 | $this->app->setEndpointConfig($method, [ |
65 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
65 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
66 | 66 | ]); |
67 | 67 | |
68 | 68 | return $this->request($method, [ |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $method = 'alipay.trade.precreate'; |
87 | 87 | $this->app->setEndpointConfig($method, [ |
88 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
88 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
89 | 89 | ]); |
90 | 90 | |
91 | 91 | return $this->request($method, [ |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return !($this->checkEmpty($value)); |
119 | 119 | }); |
120 | 120 | $this->app->setEndpointConfig($method, [ |
121 | - 'notify_url' => $this->app['config']->get('notify_url'), |
|
121 | + 'notify_url' => $this->app[ 'config' ]->get('notify_url'), |
|
122 | 122 | ]); |
123 | 123 | |
124 | 124 | return $this->request($method, [ |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException |
141 | 141 | * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException |
142 | 142 | */ |
143 | - public function refund(string $tradeNo, $amount, string $outTradeNo = null, array $params = []) |
|
143 | + public function refund(string $tradeNo, $amount, string $outTradeNo = null, array $params = [ ]) |
|
144 | 144 | { |
145 | 145 | $params = array_merge(array_filter([ |
146 | 146 | 'trade_no' => $tradeNo, |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function orderSettle(string $outRequestNo, string $tradeNo, array $royaltyParameters, string $operatorId = null) |
227 | 227 | { |
228 | - $royalty = []; |
|
228 | + $royalty = [ ]; |
|
229 | 229 | if (count($royaltyParameters) === count($royaltyParameters, COUNT_RECURSIVE)) { |
230 | - $royalty[0] = $royaltyParameters; |
|
230 | + $royalty[ 0 ] = $royaltyParameters; |
|
231 | 231 | } else { |
232 | 232 | $royalty = $royaltyParameters; |
233 | 233 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | }); |
273 | 273 | |
274 | 274 | if (!($this->checkEmpty($orderBizInfo))) { |
275 | - $params['order_biz_info'] = json_encode(['status' => $orderBizInfo]); |
|
275 | + $params[ 'order_biz_info' ] = json_encode([ 'status' => $orderBizInfo ]); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $this->request('alipay.trade.orderinfo.sync', [ |