@@ -14,6 +14,6 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($message, $raw = []) |
16 | 16 | { |
17 | - parent::__construct('INVALID_ARGUMENT: '.$message, $raw, self::INVALID_ARGUMENT); |
|
17 | + parent::__construct('INVALID_ARGUMENT: ' . $message, $raw, self::INVALID_ARGUMENT); |
|
18 | 18 | } |
19 | 19 | } |
@@ -15,6 +15,6 @@ |
||
15 | 15 | */ |
16 | 16 | public function __construct($message, $raw = [], $code = self::ERROR_GATEWAY) |
17 | 17 | { |
18 | - parent::__construct('ERROR_GATEWAY: '.$message, $raw, $code); |
|
18 | + parent::__construct('ERROR_GATEWAY: ' . $message, $raw, $code); |
|
19 | 19 | } |
20 | 20 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function requestApi($endpoint, $data, $cert = false): Collection |
161 | 161 | { |
162 | - Events::dispatch(new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri().$endpoint, $data)); |
|
162 | + Events::dispatch(new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri() . $endpoint, $data)); |
|
163 | 163 | |
164 | 164 | $result = self::$instance->post( |
165 | 165 | $endpoint, |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ); |
172 | 172 | $result = is_array($result) ? $result : self::fromXml($result); |
173 | 173 | |
174 | - Events::dispatch(new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri().$endpoint, $result)); |
|
174 | + Events::dispatch(new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri() . $endpoint, $result)); |
|
175 | 175 | |
176 | 176 | return self::processingApiResult($endpoint, $result); |
177 | 177 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $payload['appid'] = self::$instance->getConfig($type, ''); |
201 | 201 | |
202 | 202 | if (self::$instance->getConfig('mode', Wechat::MODE_NORMAL) === Wechat::MODE_SERVICE) { |
203 | - $payload['sub_appid'] = self::$instance->getConfig('sub_'.$type, ''); |
|
203 | + $payload['sub_appid'] = self::$instance->getConfig('sub_' . $type, ''); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | unset($payload['trade_type'], $payload['type']); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | ksort($data); |
236 | 236 | |
237 | - $string = md5(self::getSignContent($data).'&key='.$key); |
|
237 | + $string = md5(self::getSignContent($data) . '&key=' . $key); |
|
238 | 238 | |
239 | 239 | Log::debug('Wechat Generate Sign Before UPPER', [$data, $string]); |
240 | 240 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $buff = ''; |
256 | 256 | |
257 | 257 | foreach ($data as $k => $v) { |
258 | - $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
258 | + $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | Log::debug('Wechat Generate Sign Content Before Trim', [$data, $buff]); |
@@ -301,8 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | $xml = '<xml>'; |
303 | 303 | foreach ($data as $key => $val) { |
304 | - $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' : |
|
305 | - '<'.$key.'><![CDATA['.$val.']]></'.$key.'>'; |
|
304 | + $xml .= is_numeric($val) ? '<' . $key . '>' . $val . '</' . $key . '>' : '<' . $key . '><![CDATA[' . $val . ']]></' . $key . '>'; |
|
306 | 305 | } |
307 | 306 | $xml .= '</xml>'; |
308 | 307 | |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | $type = 'appid'; |
374 | 373 | break; |
375 | 374 | default: |
376 | - $type = $type.'_id'; |
|
375 | + $type = $type . '_id'; |
|
377 | 376 | } |
378 | 377 | |
379 | 378 | return $type; |
@@ -409,14 +408,14 @@ discard block |
||
409 | 408 | { |
410 | 409 | if (!isset($result['return_code']) || $result['return_code'] != 'SUCCESS') { |
411 | 410 | throw new GatewayException( |
412 | - 'Get Wechat API Error:'.($result['return_msg'] ?? $result['retmsg'] ?? ''), |
|
411 | + 'Get Wechat API Error:' . ($result['return_msg'] ?? $result['retmsg'] ?? ''), |
|
413 | 412 | $result |
414 | 413 | ); |
415 | 414 | } |
416 | 415 | |
417 | 416 | if (isset($result['result_code']) && $result['result_code'] != 'SUCCESS') { |
418 | 417 | throw new BusinessException( |
419 | - 'Wechat Business Error: '.$result['err_code'].' - '.$result['err_code_des'], |
|
418 | + 'Wechat Business Error: ' . $result['err_code'] . ' - ' . $result['err_code_des'], |
|
420 | 419 | $result |
421 | 420 | ); |
422 | 421 | } |
@@ -71,13 +71,13 @@ |
||
71 | 71 | protected function buildPayHtml($endpoint, $payload, $method = 'POST'): Response |
72 | 72 | { |
73 | 73 | if (strtoupper($method) === 'GET') { |
74 | - return RedirectResponse::create($endpoint.'&'.http_build_query($payload)); |
|
74 | + return RedirectResponse::create($endpoint . '&' . http_build_query($payload)); |
|
75 | 75 | } |
76 | 76 | |
77 | - $sHtml = "<form id='alipay_submit' name='alipay_submit' action='".$endpoint."' method='".$method."'>"; |
|
77 | + $sHtml = "<form id='alipay_submit' name='alipay_submit' action='" . $endpoint . "' method='" . $method . "'>"; |
|
78 | 78 | foreach ($payload as $key => $val) { |
79 | 79 | $val = str_replace("'", ''', $val); |
80 | - $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>"; |
|
80 | + $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; |
|
81 | 81 | } |
82 | 82 | $sHtml .= "<input type='submit' value='ok' style='display:none;'></form>"; |
83 | 83 | $sHtml .= "<script>document.forms['alipay_submit'].submit();</script>"; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $this->payload['biz_content'] = json_encode($params); |
143 | 143 | |
144 | - $gateway = get_class($this).'\\'.Str::studly($gateway).'Gateway'; |
|
144 | + $gateway = get_class($this) . '\\' . Str::studly($gateway) . 'Gateway'; |
|
145 | 145 | |
146 | 146 | if (class_exists($gateway)) { |
147 | 147 | return $this->makePay($gateway); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function find($order, string $type = 'wap'): Collection |
204 | 204 | { |
205 | - $gateway = get_class($this).'\\'.Str::studly($type).'Gateway'; |
|
205 | + $gateway = get_class($this) . '\\' . Str::studly($type) . 'Gateway'; |
|
206 | 206 | |
207 | 207 | if (!class_exists($gateway) || !is_callable([new $gateway(), 'find'])) { |
208 | 208 | throw new GatewayException("{$gateway} Done Not Exist Or Done Not Has FIND Method"); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $app = new $gateway(); |
395 | 395 | |
396 | 396 | if ($app instanceof GatewayInterface) { |
397 | - return $app->pay($this->gateway, array_filter($this->payload, function ($value) { |
|
397 | + return $app->pay($this->gateway, array_filter($this->payload, function($value) { |
|
398 | 398 | return $value !== '' && !is_null($value); |
399 | 399 | })); |
400 | 400 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | Events::dispatch(new Events\MethodCalled( |
431 | 431 | 'Alipay', |
432 | - 'extend - '.$method, |
|
432 | + 'extend - ' . $method, |
|
433 | 433 | $this->gateway, |
434 | 434 | is_array($customize) ? $customize : $customize->toArray() |
435 | 435 | )); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | Events::dispatch(new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data)); |
127 | 127 | |
128 | - $data = array_filter($data, function ($value) { |
|
128 | + $data = array_filter($data, function($value) { |
|
129 | 129 | return ($value == '' || is_null($value)) ? false : true; |
130 | 130 | }); |
131 | 131 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | |
158 | 158 | if (Str::endsWith($privateKey, '.pem')) { |
159 | 159 | $privateKey = openssl_pkey_get_private( |
160 | - Str::startsWith($privateKey, 'file://') ? $privateKey : 'file://'.$privateKey |
|
160 | + Str::startsWith($privateKey, 'file://') ? $privateKey : 'file://' . $privateKey |
|
161 | 161 | ); |
162 | - } else { |
|
163 | - $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n". |
|
164 | - wordwrap($privateKey, 64, "\n", true). |
|
162 | + }else { |
|
163 | + $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
164 | + wordwrap($privateKey, 64, "\n", true) . |
|
165 | 165 | "\n-----END RSA PRIVATE KEY-----"; |
166 | 166 | } |
167 | 167 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | |
202 | 202 | if (Str::endsWith($publicKey, '.pem')) { |
203 | 203 | $publicKey = openssl_pkey_get_public( |
204 | - Str::startsWith($publicKey, 'file://') ? $publicKey : 'file://'.$publicKey |
|
204 | + Str::startsWith($publicKey, 'file://') ? $publicKey : 'file://' . $publicKey |
|
205 | 205 | ); |
206 | - } else { |
|
207 | - $publicKey = "-----BEGIN PUBLIC KEY-----\n". |
|
208 | - wordwrap($publicKey, 64, "\n", true). |
|
206 | + }else { |
|
207 | + $publicKey = "-----BEGIN PUBLIC KEY-----\n" . |
|
208 | + wordwrap($publicKey, 64, "\n", true) . |
|
209 | 209 | "\n-----END PUBLIC KEY-----"; |
210 | 210 | } |
211 | 211 | |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | $stringToBeSigned = ''; |
240 | 240 | foreach ($data as $k => $v) { |
241 | 241 | if ($verify && $k != 'sign' && $k != 'sign_type') { |
242 | - $stringToBeSigned .= $k.'='.$v.'&'; |
|
242 | + $stringToBeSigned .= $k . '=' . $v . '&'; |
|
243 | 243 | } |
244 | 244 | if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) { |
245 | - $stringToBeSigned .= $k.'='.$v.'&'; |
|
245 | + $stringToBeSigned .= $k . '=' . $v . '&'; |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -318,12 +318,12 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected static function processingApiResult($data, $result): Collection |
320 | 320 | { |
321 | - $method = str_replace('.', '_', $data['method']).'_response'; |
|
321 | + $method = str_replace('.', '_', $data['method']) . '_response'; |
|
322 | 322 | |
323 | 323 | if (!isset($result['sign']) || $result[$method]['code'] != '10000') { |
324 | 324 | throw new GatewayException( |
325 | - 'Get Alipay API Error:'.$result[$method]['msg']. |
|
326 | - (isset($result[$method]['sub_code']) ? (' - '.$result[$method]['sub_code']) : ''), |
|
325 | + 'Get Alipay API Error:' . $result[$method]['msg'] . |
|
326 | + (isset($result[$method]['sub_code']) ? (' - ' . $result[$method]['sub_code']) : ''), |
|
327 | 327 | $result |
328 | 328 | ); |
329 | 329 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function pay($endpoint, array $payload): Collection |
33 | 33 | { |
34 | - $biz_array=json_decode($payload['biz_content'], true); |
|
34 | + $biz_array = json_decode($payload['biz_content'], true); |
|
35 | 35 | if (empty($biz_array['buyer_id'])) { |
36 | 36 | throw new InvalidArgumentException('buyer_id required'); |
37 | 37 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $payload['method'] = 'alipay.trade.app.pay'; |
28 | 28 | |
29 | - $biz_array=json_decode($payload['biz_content'], true); |
|
29 | + $biz_array = json_decode($payload['biz_content'], true); |
|
30 | 30 | |
31 | 31 | if (($this->mode === Alipay::MODE_SERVICE) && (!empty(Support::getInstance()->pid))) { |
32 | 32 | //服务商模式且服务商pid参数不为空 |