@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | $data = $this->preOrder(); |
40 | 40 | |
41 | - return is_null($this->user_config->get('return_url')) ? $data['MWEB_URL'] : $data['MWEB_URL']. |
|
42 | - '&redirect_url='. urlencode($this->config['return_url']); |
|
41 | + return is_null($this->user_config->get('return_url')) ? $data['MWEB_URL'] : $data['MWEB_URL'] . |
|
42 | + '&redirect_url=' . urlencode($this->config['return_url']); |
|
43 | 43 | } |
44 | 44 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function gateway($gateway = 'web') |
82 | 82 | { |
83 | - if (! isset($this->drivers)) { |
|
83 | + if (!isset($this->drivers)) { |
|
84 | 84 | throw new InvalidArgumentException("Driver is not defined."); |
85 | 85 | } |
86 | 86 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | private function createGateway($gateway) |
104 | 104 | { |
105 | - if (! file_exists(__DIR__ . '/Gateways/' . ucfirst($this->drivers) . '/' . ucfirst($gateway) . 'Gateway.php')) { |
|
105 | + if (!file_exists(__DIR__ . '/Gateways/' . ucfirst($this->drivers) . '/' . ucfirst($gateway) . 'Gateway.php')) { |
|
106 | 106 | throw new InvalidArgumentException("Gateway [$gateway] is not supported."); |
107 | 107 | } |
108 | 108 |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function buildPayHtml() |
198 | 198 | { |
199 | - $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->gateway."?charset=utf-8' method='POST'>"; |
|
200 | - while (list ($key, $val) = each ($this->config)) { |
|
201 | - $val = str_replace("'","'",$val); |
|
202 | - $sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>"; |
|
199 | + $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . $this->gateway . "?charset=utf-8' method='POST'>"; |
|
200 | + while (list ($key, $val) = each($this->config)) { |
|
201 | + $val = str_replace("'", "'", $val); |
|
202 | + $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; |
|
203 | 203 | } |
204 | - $sHtml = $sHtml."<input type='submit' value='ok' style='display:none;''></form>"; |
|
205 | - $sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>"; |
|
204 | + $sHtml = $sHtml . "<input type='submit' value='ok' style='display:none;''></form>"; |
|
205 | + $sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>"; |
|
206 | 206 | |
207 | 207 | return $sHtml; |
208 | 208 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | $data = json_decode($this->post($this->gateway, $this->config), true); |
226 | 226 | |
227 | - if (! isset($data[$method]['code']) || $data[$method]['code'] !== '10000') { |
|
227 | + if (!isset($data[$method]['code']) || $data[$method]['code'] !== '10000') { |
|
228 | 228 | throw new GatewayException( |
229 | 229 | 'get result error:' . $data[$method]['msg'] . ' - ' . $data[$method]['sub_msg'], |
230 | 230 | $data[$method]['code'], |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS' || $data['result_code'] !== 'SUCCESS') { |
149 | 149 | $error = 'preOrder error:' . $data['return_msg']; |
150 | - $error .= isset($data['err_code_des']) ? ' - ' . $data['err_code_des'] : ''; |
|
150 | + $error .= isset($data['err_code_des']) ? ' - ' . $data['err_code_des'] : ''; |
|
151 | 151 | |
152 | 152 | throw new GatewayException( |
153 | 153 | $error, |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | foreach ($data as $k => $v) |
208 | 208 | { |
209 | - if($k != "sign" && $v != "" && !is_array($v)){ |
|
209 | + if ($k != "sign" && $v != "" && !is_array($v)) { |
|
210 | 210 | $buff .= $k . "=" . $v . "&"; |
211 | 211 | } |
212 | 212 | } |
@@ -248,19 +248,19 @@ discard block |
||
248 | 248 | */ |
249 | 249 | protected function toXml($data) |
250 | 250 | { |
251 | - if(!is_array($data) || count($data) <= 0){ |
|
251 | + if (!is_array($data) || count($data) <= 0) { |
|
252 | 252 | throw new InvalidArgumentException("convert to xml error!invalid array!"); |
253 | 253 | } |
254 | 254 | |
255 | 255 | $xml = "<xml>"; |
256 | - foreach ($data as $key => $val){ |
|
257 | - if (is_numeric($val)){ |
|
258 | - $xml.="<".$key.">".$val."</".$key.">"; |
|
259 | - }else{ |
|
260 | - $xml.="<".$key."><![CDATA[".$val."]]></".$key.">"; |
|
256 | + foreach ($data as $key => $val) { |
|
257 | + if (is_numeric($val)) { |
|
258 | + $xml .= "<" . $key . ">" . $val . "</" . $key . ">"; |
|
259 | + }else { |
|
260 | + $xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">"; |
|
261 | 261 | } |
262 | 262 | } |
263 | - $xml.="</xml>"; |
|
263 | + $xml .= "</xml>"; |
|
264 | 264 | |
265 | 265 | return $xml; |
266 | 266 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | protected function fromXml($xml) |
280 | 280 | { |
281 | - if(!$xml){ |
|
281 | + if (!$xml) { |
|
282 | 282 | throw new InvalidArgumentException("convert to array error !invalid xml"); |
283 | 283 | } |
284 | 284 |
@@ -54,7 +54,7 @@ |
||
54 | 54 | 'form_params' => $params, |
55 | 55 | ]; |
56 | 56 | |
57 | - if (! is_null($body)) { |
|
57 | + if (!is_null($body)) { |
|
58 | 58 | $options = [ |
59 | 59 | 'headers' => $headers, |
60 | 60 | 'body' => $body, |