Completed
Pull Request — master (#251)
by yi
01:49
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/Alipay.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         $this->payload['biz_content'] = json_encode($params);
128 128
 
129
-        $gateway = get_class($this).'\\'.Str::studly($gateway).'Gateway';
129
+        $gateway = get_class($this) . '\\' . Str::studly($gateway) . 'Gateway';
130 130
 
131 131
         if (class_exists($gateway)) {
132 132
             return $this->makePay($gateway);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $type = 'wap';
204 204
         }
205 205
 
206
-        $gateway = get_class($this).'\\'.Str::studly($type).'Gateway';
206
+        $gateway = get_class($this) . '\\' . Str::studly($type) . 'Gateway';
207 207
 
208 208
         if (!class_exists($gateway) || !is_callable([new $gateway(), 'find'])) {
209 209
             throw new GatewayException("{$gateway} Done Not Exist Or Done Not Has FIND Method");
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         $app = new $gateway();
363 363
 
364 364
         if ($app instanceof GatewayInterface) {
365
-            return $app->pay($this->gateway, array_filter($this->payload, function ($value) {
365
+            return $app->pay($this->gateway, array_filter($this->payload, function($value) {
366 366
                 return $value !== '' && !is_null($value);
367 367
             }));
368 368
         }
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 (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("'", '&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/Alipay/Support.php 1 patch
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         Events::dispatch(Events::API_REQUESTING, 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
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 
160 160
         if (Str::endsWith($privateKey, '.pem')) {
161 161
             $privateKey = openssl_pkey_get_private($privateKey);
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,18 +201,17 @@  discard block
 block discarded – undo
201 201
 
202 202
         if (Str::endsWith($publicKey, '.pem')) {
203 203
             $publicKey = openssl_pkey_get_public($publicKey);
204
-        } else {
205
-            $publicKey = "-----BEGIN PUBLIC KEY-----\n".
206
-                wordwrap($publicKey, 64, "\n", true).
204
+        }else {
205
+            $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
206
+                wordwrap($publicKey, 64, "\n", true) .
207 207
                 "\n-----END PUBLIC KEY-----";
208 208
         }
209 209
 
210 210
         $sign = $sign ?? $data['sign'];
211 211
 
212
-        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') :
213
-                            self::getSignContent($data, true);
212
+        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : self::getSignContent($data, true);
214 213
 
215
-        $isVerify=openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1;
214
+        $isVerify = openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1;
216 215
 
217 216
         if (is_resource($publicKey)) {
218 217
             openssl_free_key($publicKey);
@@ -240,10 +239,10 @@  discard block
 block discarded – undo
240 239
         $stringToBeSigned = '';
241 240
         foreach ($data as $k => $v) {
242 241
             if ($verify && $k != 'sign' && $k != 'sign_type') {
243
-                $stringToBeSigned .= $k.'='.$v.'&';
242
+                $stringToBeSigned .= $k . '=' . $v . '&';
244 243
             }
245 244
             if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) {
246
-                $stringToBeSigned .= $k.'='.$v.'&';
245
+                $stringToBeSigned .= $k . '=' . $v . '&';
247 246
             }
248 247
         }
249 248
 
@@ -319,12 +318,12 @@  discard block
 block discarded – undo
319 318
      */
320 319
     protected static function processingApiResult($data, $result): Collection
321 320
     {
322
-        $method = str_replace('.', '_', $data['method']).'_response';
321
+        $method = str_replace('.', '_', $data['method']) . '_response';
323 322
 
324 323
         if (!isset($result['sign']) || $result[$method]['code'] != '10000') {
325 324
             throw new GatewayException(
326
-                'Get Alipay API Error:'.$result[$method]['msg'].
327
-                    (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']) : ''),
328 327
                 $result
329 328
             );
330 329
         }
Please login to merge, or discard this patch.