Completed
Push — master ( 7d5a91...7e1156 )
by Songda
01:59
created
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.