@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function buildPayHtml() |
200 | 200 | { |
201 | - $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->gateway."?charset=utf-8' method='POST'>"; |
|
202 | - while (list ($key, $val) = each ($this->config)) { |
|
203 | - $val = str_replace("'","'",$val); |
|
204 | - $sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>"; |
|
201 | + $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . $this->gateway . "?charset=utf-8' method='POST'>"; |
|
202 | + while (list ($key, $val) = each($this->config)) { |
|
203 | + $val = str_replace("'", "'", $val); |
|
204 | + $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; |
|
205 | 205 | } |
206 | - $sHtml = $sHtml."<input type='submit' value='ok' style='display:none;''></form>"; |
|
207 | - $sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>"; |
|
206 | + $sHtml = $sHtml . "<input type='submit' value='ok' style='display:none;''></form>"; |
|
207 | + $sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>"; |
|
208 | 208 | |
209 | 209 | return $sHtml; |
210 | 210 | } |
@@ -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'], |
@@ -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 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | foreach ($data as $k => $v) |
195 | 195 | { |
196 | - if($k != "sign" && $v != "" && !is_array($v)){ |
|
196 | + if ($k != "sign" && $v != "" && !is_array($v)) { |
|
197 | 197 | $buff .= $k . "=" . $v . "&"; |
198 | 198 | } |
199 | 199 | } |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | */ |
236 | 236 | protected function toXml($data) |
237 | 237 | { |
238 | - if(!is_array($data) || count($data) <= 0){ |
|
238 | + if (!is_array($data) || count($data) <= 0) { |
|
239 | 239 | throw new InvalidArgumentException("convert to xml error!invalid array!"); |
240 | 240 | } |
241 | 241 | |
242 | 242 | $xml = "<xml>"; |
243 | - foreach ($data as $key => $val){ |
|
244 | - if (is_numeric($val)){ |
|
245 | - $xml.="<".$key.">".$val."</".$key.">"; |
|
246 | - }else{ |
|
247 | - $xml.="<".$key."><![CDATA[".$val."]]></".$key.">"; |
|
243 | + foreach ($data as $key => $val) { |
|
244 | + if (is_numeric($val)) { |
|
245 | + $xml .= "<" . $key . ">" . $val . "</" . $key . ">"; |
|
246 | + }else { |
|
247 | + $xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">"; |
|
248 | 248 | } |
249 | 249 | } |
250 | - $xml.="</xml>"; |
|
250 | + $xml .= "</xml>"; |
|
251 | 251 | |
252 | 252 | return $xml; |
253 | 253 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | protected function fromXml($xml) |
267 | 267 | { |
268 | - if(!$xml){ |
|
268 | + if (!$xml) { |
|
269 | 269 | throw new InvalidArgumentException("convert to array error !invalid xml"); |
270 | 270 | } |
271 | 271 |
@@ -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 |