@@ -40,7 +40,7 @@ |
||
40 | 40 | 'appId' => !$this->payRequestUseSubAppId ? $payload['appid'] : $payload['sub_appid'], |
41 | 41 | 'timeStamp' => strval(time()), |
42 | 42 | 'nonceStr' => Str::random(), |
43 | - 'package' => 'prepay_id='.$this->preOrder($payload)->get('prepay_id'), |
|
43 | + 'package' => 'prepay_id=' . $this->preOrder($payload)->get('prepay_id'), |
|
44 | 44 | 'signType' => 'MD5', |
45 | 45 | ]; |
46 | 46 | $pay_request['paySign'] = Support::generateSign($pay_request); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public static function requestApi($endpoint, $data, $cert = false): Collection |
153 | 153 | { |
154 | - Events::dispatch(new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri().$endpoint, $data)); |
|
154 | + Events::dispatch(new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri() . $endpoint, $data)); |
|
155 | 155 | |
156 | 156 | $result = self::$instance->post( |
157 | 157 | $endpoint, |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | ); |
164 | 164 | $result = is_array($result) ? $result : self::fromXml($result); |
165 | 165 | |
166 | - Events::dispatch(new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri().$endpoint, $result)); |
|
166 | + Events::dispatch(new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri() . $endpoint, $result)); |
|
167 | 167 | |
168 | 168 | return self::processingApiResult($endpoint, $result); |
169 | 169 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $payload['appid'] = self::$instance->getConfig($type, ''); |
191 | 191 | |
192 | 192 | if (Wechat::MODE_SERVICE === self::$instance->getConfig('mode', Wechat::MODE_NORMAL)) { |
193 | - $payload['sub_appid'] = self::$instance->getConfig('sub_'.$type, ''); |
|
193 | + $payload['sub_appid'] = self::$instance->getConfig('sub_' . $type, ''); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | unset($payload['trade_type'], $payload['type']); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | ksort($data); |
224 | 224 | |
225 | - $string = md5(self::getSignContent($data).'&key='.$key); |
|
225 | + $string = md5(self::getSignContent($data) . '&key=' . $key); |
|
226 | 226 | |
227 | 227 | Log::debug('Wechat Generate Sign Before UPPER', [$data, $string]); |
228 | 228 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $buff = ''; |
242 | 242 | |
243 | 243 | foreach ($data as $k => $v) { |
244 | - $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : ''; |
|
244 | + $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : ''; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | Log::debug('Wechat Generate Sign Content Before Trim', [$data, $buff]); |
@@ -283,8 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $xml = '<xml>'; |
285 | 285 | foreach ($data as $key => $val) { |
286 | - $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' : |
|
287 | - '<'.$key.'><![CDATA['.$val.']]></'.$key.'>'; |
|
286 | + $xml .= is_numeric($val) ? '<' . $key . '>' . $val . '</' . $key . '>' : '<' . $key . '><![CDATA[' . $val . ']]></' . $key . '>'; |
|
288 | 287 | } |
289 | 288 | $xml .= '</xml>'; |
290 | 289 | |
@@ -351,7 +350,7 @@ discard block |
||
351 | 350 | $type = 'appid'; |
352 | 351 | break; |
353 | 352 | default: |
354 | - $type = $type.'_id'; |
|
353 | + $type = $type . '_id'; |
|
355 | 354 | } |
356 | 355 | |
357 | 356 | return $type; |
@@ -385,11 +384,11 @@ discard block |
||
385 | 384 | protected static function processingApiResult($endpoint, array $result) |
386 | 385 | { |
387 | 386 | if (!isset($result['return_code']) || 'SUCCESS' != $result['return_code']) { |
388 | - throw new GatewayException('Get Wechat API Error:'.($result['return_msg'] ?? $result['retmsg'] ?? ''), $result); |
|
387 | + throw new GatewayException('Get Wechat API Error:' . ($result['return_msg'] ?? $result['retmsg'] ?? ''), $result); |
|
389 | 388 | } |
390 | 389 | |
391 | 390 | if (isset($result['result_code']) && 'SUCCESS' != $result['result_code']) { |
392 | - throw new BusinessException('Wechat Business Error: '.$result['err_code'].' - '.$result['err_code_des'], $result); |
|
391 | + throw new BusinessException('Wechat Business Error: ' . $result['err_code'] . ' - ' . $result['err_code_des'], $result); |
|
393 | 392 | } |
394 | 393 | |
395 | 394 | if ('pay/getsignkey' === $endpoint || |
@@ -29,8 +29,8 @@ |
||
29 | 29 | |
30 | 30 | $mweb_url = $this->preOrder($payload)->get('mweb_url'); |
31 | 31 | |
32 | - $url = is_null(Support::getInstance()->return_url) ? $mweb_url : $mweb_url. |
|
33 | - '&redirect_url='.urlencode(Support::getInstance()->return_url); |
|
32 | + $url = is_null(Support::getInstance()->return_url) ? $mweb_url : $mweb_url . |
|
33 | + '&redirect_url=' . urlencode(Support::getInstance()->return_url); |
|
34 | 34 | |
35 | 35 | return new RedirectResponse($url); |
36 | 36 | } |
@@ -68,13 +68,13 @@ |
||
68 | 68 | protected function buildPayHtml($endpoint, $payload, $method = 'POST'): Response |
69 | 69 | { |
70 | 70 | if ('GET' === strtoupper($method)) { |
71 | - return new RedirectResponse($endpoint.'&'.http_build_query($payload)); |
|
71 | + return new RedirectResponse($endpoint . '&' . http_build_query($payload)); |
|
72 | 72 | } |
73 | 73 | |
74 | - $sHtml = "<form id='alipay_submit' name='alipay_submit' action='".$endpoint."' method='".$method."'>"; |
|
74 | + $sHtml = "<form id='alipay_submit' name='alipay_submit' action='" . $endpoint . "' method='" . $method . "'>"; |
|
75 | 75 | foreach ($payload as $key => $val) { |
76 | 76 | $val = str_replace("'", ''', $val); |
77 | - $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>"; |
|
77 | + $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; |
|
78 | 78 | } |
79 | 79 | $sHtml .= "<input type='submit' value='ok' style='display:none;'></form>"; |
80 | 80 | $sHtml .= "<script>document.forms['alipay_submit'].submit();</script>"; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | { |
137 | 137 | Events::dispatch(new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data)); |
138 | 138 | |
139 | - $data = array_filter($data, function ($value) { |
|
139 | + $data = array_filter($data, function($value) { |
|
140 | 140 | return ('' == $value || is_null($value)) ? false : true; |
141 | 141 | }); |
142 | 142 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | |
165 | 165 | if (Str::endsWith($privateKey, '.pem')) { |
166 | 166 | $privateKey = openssl_pkey_get_private( |
167 | - Str::startsWith($privateKey, 'file://') ? $privateKey : 'file://'.$privateKey |
|
167 | + Str::startsWith($privateKey, 'file://') ? $privateKey : 'file://' . $privateKey |
|
168 | 168 | ); |
169 | - } else { |
|
170 | - $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n". |
|
171 | - wordwrap($privateKey, 64, "\n", true). |
|
169 | + }else { |
|
170 | + $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
171 | + wordwrap($privateKey, 64, "\n", true) . |
|
172 | 172 | "\n-----END RSA PRIVATE KEY-----"; |
173 | 173 | } |
174 | 174 | |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | $publicKey = file_get_contents($publicKey); |
208 | 208 | } elseif (Str::endsWith($publicKey, '.pem')) { |
209 | 209 | $publicKey = openssl_pkey_get_public( |
210 | - Str::startsWith($publicKey, 'file://') ? $publicKey : 'file://'.$publicKey |
|
210 | + Str::startsWith($publicKey, 'file://') ? $publicKey : 'file://' . $publicKey |
|
211 | 211 | ); |
212 | - } else { |
|
213 | - $publicKey = "-----BEGIN PUBLIC KEY-----\n". |
|
214 | - wordwrap($publicKey, 64, "\n", true). |
|
212 | + }else { |
|
213 | + $publicKey = "-----BEGIN PUBLIC KEY-----\n" . |
|
214 | + wordwrap($publicKey, 64, "\n", true) . |
|
215 | 215 | "\n-----END PUBLIC KEY-----"; |
216 | 216 | } |
217 | 217 | |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | $stringToBeSigned = ''; |
243 | 243 | foreach ($data as $k => $v) { |
244 | 244 | if ($verify && 'sign' != $k && 'sign_type' != $k) { |
245 | - $stringToBeSigned .= $k.'='.$v.'&'; |
|
245 | + $stringToBeSigned .= $k . '=' . $v . '&'; |
|
246 | 246 | } |
247 | 247 | if (!$verify && '' !== $v && !is_null($v) && 'sign' != $k && '@' != substr($v, 0, 1)) { |
248 | - $stringToBeSigned .= $k.'='.$v.'&'; |
|
248 | + $stringToBeSigned .= $k . '=' . $v . '&'; |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | } |
329 | 329 | $issuer_arr = []; |
330 | 330 | foreach ($certdata['issuer'] as $key => $val) { |
331 | - $issuer_arr[] = $key.'='.$val; |
|
331 | + $issuer_arr[] = $key . '=' . $val; |
|
332 | 332 | } |
333 | 333 | $issuer = implode(',', array_reverse($issuer_arr)); |
334 | 334 | Log::debug('getCertSN:', [$certPath, $issuer, $certdata['serialNumber']]); |
335 | 335 | |
336 | - return md5($issuer.$certdata['serialNumber']); |
|
336 | + return md5($issuer . $certdata['serialNumber']); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -361,21 +361,21 @@ discard block |
||
361 | 361 | $md5_arr = []; |
362 | 362 | foreach ($certStrList as $one) { |
363 | 363 | if (!empty(trim($one))) { |
364 | - $_x509data = $one.$kCertificateEnd; |
|
364 | + $_x509data = $one . $kCertificateEnd; |
|
365 | 365 | openssl_x509_read($_x509data); |
366 | 366 | $_certdata = openssl_x509_parse($_x509data); |
367 | 367 | if (in_array($_certdata['signatureTypeSN'], ['RSA-SHA256', 'RSA-SHA1'])) { |
368 | 368 | $issuer_arr = []; |
369 | 369 | foreach ($_certdata['issuer'] as $key => $val) { |
370 | - $issuer_arr[] = $key.'='.$val; |
|
370 | + $issuer_arr[] = $key . '=' . $val; |
|
371 | 371 | } |
372 | 372 | $_issuer = implode(',', array_reverse($issuer_arr)); |
373 | 373 | if (0 === strpos($_certdata['serialNumber'], '0x')) { |
374 | 374 | $serialNumber = self::bchexdec($_certdata['serialNumber']); |
375 | - } else { |
|
375 | + }else { |
|
376 | 376 | $serialNumber = $_certdata['serialNumber']; |
377 | 377 | } |
378 | - $md5_arr[] = md5($_issuer.$serialNumber); |
|
378 | + $md5_arr[] = md5($_issuer . $serialNumber); |
|
379 | 379 | Log::debug('getRootCertSN Sub:', [$certPath, $_issuer, $serialNumber]); |
380 | 380 | } |
381 | 381 | } |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | return new Collection($result); |
403 | 403 | } |
404 | 404 | |
405 | - $method = str_replace('.', '_', $data['method']).'_response'; |
|
405 | + $method = str_replace('.', '_', $data['method']) . '_response'; |
|
406 | 406 | |
407 | 407 | if (!isset($result['sign']) || '10000' != $result[$method]['code']) { |
408 | - throw new GatewayException('Get Alipay API Error:'.$result[$method]['msg'].(isset($result[$method]['sub_code']) ? (' - '.$result[$method]['sub_code']) : ''), $result); |
|
408 | + throw new GatewayException('Get Alipay API Error:' . $result[$method]['msg'] . (isset($result[$method]['sub_code']) ? (' - ' . $result[$method]['sub_code']) : ''), $result); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | if (self::verifySign($result[$method], true, $result['sign'])) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | $this->payload['biz_content'] = json_encode($params); |
154 | 154 | |
155 | - $gateway = __CLASS__.'\\'.Str::studly($gateway).'Gateway'; |
|
155 | + $gateway = __CLASS__ . '\\' . Str::studly($gateway) . 'Gateway'; |
|
156 | 156 | |
157 | 157 | if (class_exists($gateway)) { |
158 | 158 | return $this->makePay($gateway); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function find($order, string $type = 'wap'): Collection |
209 | 209 | { |
210 | - $gateway = get_class($this).'\\'.Str::studly($type).'Gateway'; |
|
210 | + $gateway = get_class($this) . '\\' . Str::studly($type) . 'Gateway'; |
|
211 | 211 | |
212 | 212 | if (!class_exists($gateway) || !is_callable([new $gateway(), 'find'])) { |
213 | 213 | throw new GatewayException("{$gateway} Done Not Exist Or Done Not Has FIND Method"); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $app = new $gateway(); |
375 | 375 | |
376 | 376 | if ($app instanceof GatewayInterface) { |
377 | - return $app->pay($this->gateway, array_filter($this->payload, function ($value) { |
|
377 | + return $app->pay($this->gateway, array_filter($this->payload, function($value) { |
|
378 | 378 | return '' !== $value && !is_null($value); |
379 | 379 | })); |
380 | 380 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | |
407 | 407 | Events::dispatch(new Events\MethodCalled( |
408 | 408 | 'Alipay', |
409 | - 'extend - '.$method, |
|
409 | + 'extend - ' . $method, |
|
410 | 410 | $this->gateway, |
411 | 411 | is_array($customize) ? $customize : $customize->toArray() |
412 | 412 | )); |