Completed
Pull Request — master (#138)
by Jim
01:38
created
src/Gateways/Wechat.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
      * @author yansongda <[email protected]>
66 66
      *
67 67
      * @param string $gateway
68
-     * @param array  $params
68
+     * @param string  $params
69 69
      *
70 70
      * @return Response|Collection
71 71
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
     {
74 74
         $this->payload = array_merge($this->payload, $params);
75 75
 
76
-        $gateway = get_class($this).'\\'.Str::studly($gateway).'Gateway';
76
+        $gateway = get_class($this) . '\\' . Str::studly($gateway) . 'Gateway';
77 77
 
78 78
         if (class_exists($gateway)) {
79 79
             return $this->makePay($gateway);
Please login to merge, or discard this patch.
src/Pay.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     {
45 45
         !$this->config->has('log.file') ?: $this->registeLog();
46 46
 
47
-        $gateway = __NAMESPACE__.'\\Gateways\\'.Str::studly($method);
47
+        $gateway = __NAMESPACE__ . '\\Gateways\\' . Str::studly($method);
48 48
 
49 49
         if (class_exists($gateway)) {
50 50
             return self::make($gateway);
Please login to merge, or discard this patch.
src/Log.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
      */
54 54
     protected static function createDefaultLogger()
55 55
     {
56
-        $handler = new StreamHandler(sys_get_temp_dir().'/logs/yansongda.pay.log');
56
+        $handler = new StreamHandler(sys_get_temp_dir() . '/logs/yansongda.pay.log');
57 57
         $handler->setFormatter(new LineFormatter("%datetime% > %level_name% > %message% %context% %extra%\n\n"));
58 58
 
59 59
         $logger = new Logger('yansongda.pay');
Please login to merge, or discard this patch.
src/Gateways/Alipay/WebGateway.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,10 +64,10 @@
 block discarded – undo
64 64
      */
65 65
     protected function buildPayHtml($endpoint, $payload): Response
66 66
     {
67
-        $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$endpoint."' method='POST'>";
67
+        $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . $endpoint . "' method='POST'>";
68 68
         foreach ($payload as $key => $val) {
69 69
             $val = str_replace("'", '&apos;', $val);
70
-            $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>";
70
+            $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>";
71 71
         }
72 72
         $sHtml .= "<input type='submit' value='ok' style='display:none;''></form>";
73 73
         $sHtml .= "<script>document.forms['alipaysubmit'].submit();</script>";
Please login to merge, or discard this patch.
src/Gateways/Wechat/WapGateway.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 
24 24
         $data = $this->preOrder('pay/unifiedorder', $payload);
25 25
 
26
-        $url = is_null($this->config->get('return_url')) ? $data->mweb_url : $data->mweb_url.
27
-                        '&redirect_url='.urlencode($this->config->get('return_url'));
26
+        $url = is_null($this->config->get('return_url')) ? $data->mweb_url : $data->mweb_url .
27
+                        '&redirect_url=' . urlencode($this->config->get('return_url'));
28 28
 
29 29
         return RedirectResponse::create($url);
30 30
     }
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
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
             'appId'     => $payload['appid'],
27 27
             'timeStamp' => strval(time()),
28 28
             'nonceStr'  => Str::random(),
29
-            'package'   => 'prepay_id='.$this->preOrder('pay/unifiedorder', $payload)->prepay_id,
29
+            'package'   => 'prepay_id=' . $this->preOrder('pay/unifiedorder', $payload)->prepay_id,
30 30
             'signType'  => 'MD5',
31 31
         ];
32 32
         $payRequest['paySign'] = Support::generateSign($payRequest, $this->config->get('key'));
Please login to merge, or discard this patch.
src/Gateways/Wechat/TransferGateway.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
         if ($this->mode === Wechat::MODE_SERVICE) {
25 25
             unset($payload['sub_mch_id'], $payload['sub_appid']);
26 26
         }
27
-        $type = isset($payload['type']) ? ($payload['type'].($payload['type'] == 'app' ?: '_').'id') : 'app_id';
27
+        $type = isset($payload['type']) ? ($payload['type'] . ($payload['type'] == 'app' ?: '_') . 'id') : 'app_id';
28 28
 
29 29
         $payload['mch_appid'] = $this->config->get($type, '');
30 30
         $payload['mchid'] = $payload['mch_id'];
Please login to merge, or discard this patch.
src/Gateways/Alipay/Support.php 1 patch
Spacing   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
     {
60 60
         Log::debug('Request To Alipay Api', [self::getInstance()->baseUri(), $data]);
61 61
 
62
-        $data = array_filter($data, function ($value) {
62
+        $data = array_filter($data, function($value) {
63 63
             return ($value == '' || is_null($value)) ? false : true;
64 64
         });
65 65
 
66 66
         $result = mb_convert_encoding(self::getInstance()->post('', $data), 'utf-8', 'gb2312');
67 67
         $result = json_decode($result, true);
68 68
 
69
-        $method = str_replace('.', '_', $data['method']).'_response';
69
+        $method = str_replace('.', '_', $data['method']) . '_response';
70 70
 
71 71
         if (!isset($result['sign']) || !isset($result[$method]['code']) || $result[$method]['code'] != '10000') {
72 72
             throw new GatewayException(
73
-                'Get Alipay API Error:'.$result[$method]['msg'].($result[$method]['sub_code'] ?? ''),
73
+                'Get Alipay API Error:' . $result[$method]['msg'] . ($result[$method]['sub_code'] ?? ''),
74 74
                 $result,
75 75
                 $result[$method]['code']
76 76
             );
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 
104 104
         if (Str::endsWith($privateKey, '.pem')) {
105 105
             $privateKey = openssl_pkey_get_private($privateKey);
106
-        } else {
107
-            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n".
108
-                wordwrap($privateKey, 64, "\n", true).
106
+        }else {
107
+            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
108
+                wordwrap($privateKey, 64, "\n", true) .
109 109
                 "\n-----END RSA PRIVATE KEY-----";
110 110
         }
111 111
 
@@ -134,16 +134,15 @@  discard block
 block discarded – undo
134 134
 
135 135
         if (Str::endsWith($publicKey, '.pem')) {
136 136
             $publicKey = openssl_pkey_get_public($publicKey);
137
-        } else {
138
-            $publicKey = "-----BEGIN PUBLIC KEY-----\n".
139
-                wordwrap($publicKey, 64, "\n", true).
137
+        }else {
138
+            $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
139
+                wordwrap($publicKey, 64, "\n", true) .
140 140
                 "\n-----END PUBLIC KEY-----";
141 141
         }
142 142
 
143 143
         $sign = $sign ?? $data['sign'];
144 144
 
145
-        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') :
146
-                            self::getSignContent($data, true);
145
+        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : self::getSignContent($data, true);
147 146
 
148 147
         return openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1;
149 148
     }
@@ -167,10 +166,10 @@  discard block
 block discarded – undo
167 166
         $stringToBeSigned = '';
168 167
         foreach ($data as $k => $v) {
169 168
             if ($verify && $k != 'sign' && $k != 'sign_type') {
170
-                $stringToBeSigned .= $k.'='.$v.'&';
169
+                $stringToBeSigned .= $k . '=' . $v . '&';
171 170
             }
172 171
             if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) {
173
-                $stringToBeSigned .= $k.'='.$v.'&';
172
+                $stringToBeSigned .= $k . '=' . $v . '&';
174 173
             }
175 174
         }
176 175
 
Please login to merge, or discard this patch.
src/Gateways/Wechat/Support.php 1 patch
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public static function requestApi($endpoint, $data, $key = null, $cert = []): Collection
60 60
     {
61
-        Log::debug('Request To Wechat Api', [self::baseUri().$endpoint, $data]);
61
+        Log::debug('Request To Wechat Api', [self::baseUri() . $endpoint, $data]);
62 62
 
63 63
         $result = self::getInstance()->post(
64 64
             $endpoint,
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
         if (!isset($result['return_code']) || $result['return_code'] != 'SUCCESS' || $result['result_code'] != 'SUCCESS') {
71 71
             throw new GatewayException(
72
-                'Get Wechat API Error:'.$result['return_msg'].($result['err_code_des'] ?? ''),
72
+                'Get Wechat API Error:' . $result['return_msg'] . ($result['err_code_des'] ?? ''),
73 73
                 $result,
74 74
                 20000
75 75
             );
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $payload = array_merge($payload, is_array($order) ? $order : ['out_trade_no' => $order]);
101 101
 
102
-        $type = isset($order['type']) ? $order['type'].($order['type'] == 'app' ? '' : '_').'id' : 'app_id';
102
+        $type = isset($order['type']) ? $order['type'] . ($order['type'] == 'app' ? '' : '_') . 'id' : 'app_id';
103 103
         $payload['appid'] = $config->get($type, '');
104 104
 
105 105
         if ($config->get('mode', Wechat::MODE_NORMAL) === Wechat::MODE_SERVICE) {
106
-            $payload['sub_appid'] = $config->get('sub_'.$type, '');
106
+            $payload['sub_appid'] = $config->get('sub_' . $type, '');
107 107
         }
108 108
 
109 109
         unset($payload['trade_type'], $payload['type']);
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
         ksort($data);
136 136
 
137
-        $string = md5(self::getSignContent($data).'&key='.$key);
137
+        $string = md5(self::getSignContent($data) . '&key=' . $key);
138 138
 
139 139
         return strtoupper($string);
140 140
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $buff = '';
154 154
 
155 155
         foreach ($data as $k => $v) {
156
-            $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k.'='.$v.'&' : '';
156
+            $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : '';
157 157
         }
158 158
 
159 159
         return trim($buff, '&');
@@ -176,8 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         $xml = '<xml>';
178 178
         foreach ($data as $key => $val) {
179
-            $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
180
-                                       '<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
179
+            $xml .= is_numeric($val) ? '<' . $key . '>' . $val . '</' . $key . '>' : '<' . $key . '><![CDATA[' . $val . ']]></' . $key . '>';
181 180
         }
182 181
         $xml .= '</xml>';
183 182
 
Please login to merge, or discard this patch.