Completed
Pull Request — master (#251)
by yi
01:49
created
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.