Completed
Pull Request — master (#335)
by Luo
01:25
created
src/Exceptions/GatewayException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Gateways/Wechat/MpGateway.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Gateways/Alipay.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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");
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         $app = new $gateway();
390 390
 
391 391
         if ($app instanceof GatewayInterface) {
392
-            return $app->pay($this->gateway, array_filter($this->payload, function ($value) {
392
+            return $app->pay($this->gateway, array_filter($this->payload, function($value) {
393 393
                 return '' !== $value && !is_null($value);
394 394
             }));
395 395
         }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
         Events::dispatch(new Events\MethodCalled(
428 428
             'Alipay',
429
-            'extend - '.$method,
429
+            'extend - ' . $method,
430 430
             $this->gateway,
431 431
             is_array($customize) ? $customize : $customize->toArray()
432 432
         ));
Please login to merge, or discard this patch.
src/Gateways/Alipay/WebGateway.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@
 block discarded – undo
71 71
     protected function buildPayHtml($endpoint, $payload, $method = 'POST'): Response
72 72
     {
73 73
         if ('GET' === strtoupper($method)) {
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("'", '&apos;', $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>";
Please login to merge, or discard this patch.
src/Gateways/Wechat/Support.php 1 patch
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 ||
Please login to merge, or discard this patch.
src/Gateways/Alipay/Support.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     {
136 136
         Events::dispatch(new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data));
137 137
 
138
-        $data = array_filter($data, function ($value) {
138
+        $data = array_filter($data, function($value) {
139 139
             return ('' == $value || is_null($value)) ? false : true;
140 140
         });
141 141
 
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 
164 164
         if (Str::endsWith($privateKey, '.pem')) {
165 165
             $privateKey = openssl_pkey_get_private(
166
-                Str::startsWith($privateKey, 'file://') ? $privateKey : 'file://'.$privateKey
166
+                Str::startsWith($privateKey, 'file://') ? $privateKey : 'file://' . $privateKey
167 167
             );
168
-        } else {
169
-            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n".
170
-                wordwrap($privateKey, 64, "\n", true).
168
+        }else {
169
+            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
170
+                wordwrap($privateKey, 64, "\n", true) .
171 171
                 "\n-----END RSA PRIVATE KEY-----";
172 172
         }
173 173
 
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
             $publicKey = file_get_contents($publicKey);
207 207
         } elseif (Str::endsWith($publicKey, '.pem')) {
208 208
             $publicKey = openssl_pkey_get_public(
209
-                Str::startsWith($publicKey, 'file://') ? $publicKey : 'file://'.$publicKey
209
+                Str::startsWith($publicKey, 'file://') ? $publicKey : 'file://' . $publicKey
210 210
             );
211
-        } else {
212
-            $publicKey = "-----BEGIN PUBLIC KEY-----\n".
213
-                wordwrap($publicKey, 64, "\n", true).
211
+        }else {
212
+            $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
213
+                wordwrap($publicKey, 64, "\n", true) .
214 214
                 "\n-----END PUBLIC KEY-----";
215 215
         }
216 216
 
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
         $stringToBeSigned = '';
242 242
         foreach ($data as $k => $v) {
243 243
             if ($verify && 'sign' != $k && 'sign_type' != $k) {
244
-                $stringToBeSigned .= $k.'='.$v.'&';
244
+                $stringToBeSigned .= $k . '=' . $v . '&';
245 245
             }
246 246
             if (!$verify && '' !== $v && !is_null($v) && 'sign' != $k && '@' != substr($v, 0, 1)) {
247
-                $stringToBeSigned .= $k.'='.$v.'&';
247
+                $stringToBeSigned .= $k . '=' . $v . '&';
248 248
             }
249 249
         }
250 250
 
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
         }
328 328
         $issuer_arr = [];
329 329
         foreach ($certdata['issuer'] as $key => $val) {
330
-            $issuer_arr[] = $key.'='.$val;
330
+            $issuer_arr[] = $key . '=' . $val;
331 331
         }
332 332
         $issuer = implode(',', array_reverse($issuer_arr));
333 333
         Log::debug('getCertSN:', [$certPath, $issuer, $certdata['serialNumber']]);
334 334
 
335
-        return md5($issuer.$certdata['serialNumber']);
335
+        return md5($issuer . $certdata['serialNumber']);
336 336
     }
337 337
 
338 338
     /**
@@ -360,21 +360,21 @@  discard block
 block discarded – undo
360 360
         $md5_arr = [];
361 361
         foreach ($certStrList as $one) {
362 362
             if (!empty(trim($one))) {
363
-                $_x509data = $one.$kCertificateEnd;
363
+                $_x509data = $one . $kCertificateEnd;
364 364
                 openssl_x509_read($_x509data);
365 365
                 $_certdata = openssl_x509_parse($_x509data);
366 366
                 if (in_array($_certdata['signatureTypeSN'], ['RSA-SHA256', 'RSA-SHA1'])) {
367 367
                     $issuer_arr = [];
368 368
                     foreach ($_certdata['issuer'] as $key => $val) {
369
-                        $issuer_arr[] = $key.'='.$val;
369
+                        $issuer_arr[] = $key . '=' . $val;
370 370
                     }
371 371
                     $_issuer = implode(',', array_reverse($issuer_arr));
372 372
                     if (0 === strpos($_certdata['serialNumber'], '0x')) {
373 373
                         $serialNumber = self::bchexdec($_certdata['serialNumber']);
374
-                    } else {
374
+                    }else {
375 375
                         $serialNumber = $_certdata['serialNumber'];
376 376
                     }
377
-                    $md5_arr[] = md5($_issuer.$serialNumber);
377
+                    $md5_arr[] = md5($_issuer . $serialNumber);
378 378
                     Log::debug('getRootCertSN Sub:', [$certPath, $_issuer, $serialNumber]);
379 379
                 }
380 380
             }
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
      */
398 398
     protected static function processingApiResult($data, $result): Collection
399 399
     {
400
-        $method = str_replace('.', '_', $data['method']).'_response';
400
+        $method = str_replace('.', '_', $data['method']) . '_response';
401 401
 
402 402
         if (!isset($result['sign']) || '10000' != $result[$method]['code']) {
403
-            throw new GatewayException('Get Alipay API Error:'.$result[$method]['msg'].(isset($result[$method]['sub_code']) ? (' - '.$result[$method]['sub_code']) : ''), $result);
403
+            throw new GatewayException('Get Alipay API Error:' . $result[$method]['msg'] . (isset($result[$method]['sub_code']) ? (' - ' . $result[$method]['sub_code']) : ''), $result);
404 404
         }
405 405
 
406 406
         if (self::verifySign($result[$method], true, $result['sign'])) {
Please login to merge, or discard this patch.