Completed
Push — master ( a332ca...2fad31 )
by Songda
01:41
created
src/Gateways/Alipay/Support.php 1 patch
Spacing   +13 added lines, -14 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
 
@@ -197,16 +197,15 @@  discard block
 block discarded – undo
197 197
 
198 198
         if (Str::endsWith($publicKey, '.pem')) {
199 199
             $publicKey = openssl_pkey_get_public($publicKey);
200
-        } else {
201
-            $publicKey = "-----BEGIN PUBLIC KEY-----\n".
202
-                wordwrap($publicKey, 64, "\n", true).
200
+        }else {
201
+            $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
202
+                wordwrap($publicKey, 64, "\n", true) .
203 203
                 "\n-----END PUBLIC KEY-----";
204 204
         }
205 205
 
206 206
         $sign = $sign ?? $data['sign'];
207 207
 
208
-        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') :
209
-                            self::getSignContent($data, true);
208
+        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : self::getSignContent($data, true);
210 209
 
211 210
         return openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1;
212 211
     }
@@ -230,10 +229,10 @@  discard block
 block discarded – undo
230 229
         $stringToBeSigned = '';
231 230
         foreach ($data as $k => $v) {
232 231
             if ($verify && $k != 'sign' && $k != 'sign_type') {
233
-                $stringToBeSigned .= $k.'='.$v.'&';
232
+                $stringToBeSigned .= $k . '=' . $v . '&';
234 233
             }
235 234
             if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) {
236
-                $stringToBeSigned .= $k.'='.$v.'&';
235
+                $stringToBeSigned .= $k . '=' . $v . '&';
237 236
             }
238 237
         }
239 238
 
@@ -309,12 +308,12 @@  discard block
 block discarded – undo
309 308
      */
310 309
     protected static function processingApiResult($data, $result): Collection
311 310
     {
312
-        $method = str_replace('.', '_', $data['method']).'_response';
311
+        $method = str_replace('.', '_', $data['method']) . '_response';
313 312
 
314 313
         if (!isset($result['sign']) || $result[$method]['code'] != '10000') {
315 314
             throw new GatewayException(
316
-                'Get Alipay API Error:'.$result[$method]['msg'].
317
-                    (isset($result[$method]['sub_code']) ? (' - '.$result[$method]['sub_code']) : ''),
315
+                'Get Alipay API Error:' . $result[$method]['msg'] .
316
+                    (isset($result[$method]['sub_code']) ? (' - ' . $result[$method]['sub_code']) : ''),
318 317
                 $result
319 318
             );
320 319
         }
Please login to merge, or discard this patch.