Passed
Push — master ( edb5ad...501b4c )
by ma
03:22
created
src/Service/Alipay/Mp.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,5 +24,5 @@
 block discarded – undo
24 24
      * 必传的值
25 25
      * @var array
26 26
      */
27
-    protected $require = ['requestTimestamp', 'merOrderId', 'mid', 'tid', 'subAppId', 'subOpenId', 'tradeType','instMid'];
27
+    protected $require = ['requestTimestamp', 'merOrderId', 'mid', 'tid', 'subAppId', 'subOpenId', 'tradeType', 'instMid'];
28 28
 }
Please login to merge, or discard this patch.
src/Service/Common/Base.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
      * @param $config
45 45
      * @param $params
46 46
      */
47
-    public function __construct($config=[],$params=[])
47
+    public function __construct($config = [], $params = [])
48 48
     {
49
-        if(!empty($config)){
49
+        if (!empty($config)) {
50 50
             $this->config = $config;
51 51
             $this->loadConfigGateway();
52 52
         }
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
      */
60 60
     private function loadConfigGateway()
61 61
     {
62
-        $gateway = $this->config['gateway'];// 正式环境
63
-        if($this->config['sandbox'] === false){
64
-            $this->gateway = isset($gateway[$this->gateway_type]) ? $gateway[$this->gateway_type] : $gateway['default'];// 沙箱环境
65
-        }else{
66
-            $this->gateway = $gateway['sandbox'];// 沙箱环境
62
+        $gateway = $this->config['gateway']; // 正式环境
63
+        if ($this->config['sandbox'] === false) {
64
+            $this->gateway = isset($gateway[$this->gateway_type]) ? $gateway[$this->gateway_type] : $gateway['default']; // 沙箱环境
65
+        } else {
66
+            $this->gateway = $gateway['sandbox']; // 沙箱环境
67 67
         }
68 68
 
69 69
         return $this;
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function request($params = [])
94 94
     {
95
-        if(!empty($params)){
95
+        if (!empty($params)) {
96 96
             $this->params = $params;
97 97
         }
98 98
 
99 99
         try {
100 100
             $data = $this->loadData();
101 101
             $sign = $this->generateSign($data);
102
-            $gateway  = $this->gateway . $this->api;
102
+            $gateway = $this->gateway . $this->api;
103 103
 
104 104
             if ('cli' == php_sapi_name()) {
105 105
                 echo 'api:' . $gateway . PHP_EOL;
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
                 CURLOPT_CONNECTTIMEOUT => 30
117 117
             ];
118 118
             $response = Http::post($gateway, $data, $options);
119
-            $this->writeLog('Request url:'.$gateway.PHP_EOL.'params:'.json_encode($data).PHP_EOL.'options:'.json_encode($options).PHP_EOL.'response'.$response);
119
+            $this->writeLog('Request url:' . $gateway . PHP_EOL . 'params:' . json_encode($data) . PHP_EOL . 'options:' . json_encode($options) . PHP_EOL . 'response' . $response);
120 120
             return $response;
121 121
         } catch (Exception $e) {
122 122
             if ('cli' == php_sapi_name()) {
123 123
                 echo $e->getMessage() . PHP_EOL;
124 124
             }
125
-            throw new TException("Chinaums request error:".$e->getMessage());
125
+            throw new TException("Chinaums request error:" . $e->getMessage());
126 126
         }
127 127
     }
128 128
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
     {
134 134
         try {
135 135
             $data = $this->loadData();
136
-            $params = $this->generateSign($data,true);
137
-            $gateway  = $this->gateway . $this->api;
136
+            $params = $this->generateSign($data, true);
137
+            $gateway = $this->gateway . $this->api;
138 138
 
139 139
             $data = json_encode($data);
140 140
             if ('cli' == php_sapi_name()) {
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
                 CURLOPT_TIMEOUT => 60,
147 147
                 CURLOPT_CONNECTTIMEOUT => 30
148 148
             ];
149
-            $response = Http::get($gateway,$params,$options);
150
-            $this->writeLog('formRequest url:'.$gateway.PHP_EOL.'params:'.json_encode($data).PHP_EOL.'options:'.json_encode($options).PHP_EOL.'response'.$response);
149
+            $response = Http::get($gateway, $params, $options);
150
+            $this->writeLog('formRequest url:' . $gateway . PHP_EOL . 'params:' . json_encode($data) . PHP_EOL . 'options:' . json_encode($options) . PHP_EOL . 'response' . $response);
151 151
             return $response;
152 152
         } catch (Exception $e) {
153
-            throw new TException("Chinaums formRequest error:".$e->getMessage());
153
+            throw new TException("Chinaums formRequest error:" . $e->getMessage());
154 154
         }
155 155
     }
156 156
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      * @param string $signType
198 198
      * @return string
199 199
      */
200
-    public function generateSign($body,$openForm=false)
200
+    public function generateSign($body, $openForm = false)
201 201
     {
202 202
         $body = (!is_string($body)) ? json_encode($body) : $body;
203 203
         $appid = $this->config['appid'];
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $str = bin2hex(hash('sha256', $body, true));
208 208
         $signature = base64_encode(hash_hmac('sha256', "$appid$timestamp$nonce$str", $appkey, true));
209 209
         $authorization = "OPEN-BODY-SIG AppId=\"$appid\", Timestamp=\"$timestamp\", Nonce=\"$nonce\", Signature=\"$signature\"";
210
-        if($openForm){
210
+        if ($openForm) {
211 211
             $params = [
212 212
                 'appId'=>$appid,
213 213
                 'timestamp'=>$timestamp,
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
      * @param $file_name
237 237
      * @return void
238 238
      */
239
-    private function writeLog($message,$file_name = 'chinaums')
239
+    private function writeLog($message, $file_name = 'chinaums')
240 240
     {
241
-        FileTool::writeLog($message,$file_name);
241
+        FileTool::writeLog($message, $file_name);
242 242
     }
243 243
 }
Please login to merge, or discard this patch.