Completed
Push — master ( 56f964...5d7853 )
by Wei
03:04 queued 28s
created
src/WechatPay.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -655,7 +655,7 @@
 block discarded – undo
655 655
 	 * @return array
656 656
 	 */
657 657
 	public function report($interface_url,$execution_time,$return_code,$result_code,$user_ip,$out_trade_no = null,$time = null,$device_info = null,
658
-	                       $return_msg = null,$err_code = null,$err_code_des = null){
658
+						   $return_msg = null,$err_code = null,$err_code_des = null){
659 659
 		$data = array();
660 660
 		$data["appid"] = $this->config["app_id"];
661 661
 		$data["interface_url"] = $interface_url;
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 use zhangv\wechat\cache\JsonFileCacheProvider;
13 13
 
14 14
 class WechatPay {
15
-	const TRADETYPE_JSAPI = 'JSAPI',TRADETYPE_NATIVE = 'NATIVE',TRADETYPE_APP = 'APP',TRADETYPE_MWEB = 'MWEB';
15
+	const TRADETYPE_JSAPI = 'JSAPI', TRADETYPE_NATIVE = 'NATIVE', TRADETYPE_APP = 'APP', TRADETYPE_MWEB = 'MWEB';
16 16
 	const SIGNTYPE_MD5 = 'MD5', SIGNTYPE_HMACSHA256 = 'HMAC-SHA256';
17
-	const CHECKNAME_FORCECHECK = 'FORCE_CHECK',CHECKNAME_NOCHECK = 'NO_CHECK';
18
-	const ACCOUNTTYPE_BASIC = 'Basic',ACCOUNTTYPE_OPERATION = 'Operation',ACCOUNTTYPE_FEES = 'Fees';
17
+	const CHECKNAME_FORCECHECK = 'FORCE_CHECK', CHECKNAME_NOCHECK = 'NO_CHECK';
18
+	const ACCOUNTTYPE_BASIC = 'Basic', ACCOUNTTYPE_OPERATION = 'Operation', ACCOUNTTYPE_FEES = 'Fees';
19 19
 	/** 支付 */
20 20
 	const URL_UNIFIEDORDER = "https://api.mch.weixin.qq.com/pay/unifiedorder";
21 21
 	const URL_ORDERQUERY = "https://api.mch.weixin.qq.com/pay/orderquery";
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	const URL_GETPUBLICKEY = 'https://fraud.mch.weixin.qq.com/risk/getpublickey';
48 48
 	public static $BANKCODE = ['工商银行' => '1002', '农业银行' => '1005', '中国银行' => '1026', '建设银行' => '1003', '招商银行' => '1001',
49 49
 		'邮储银行' => '1066', '交通银行' => '1020', '浦发银行' => '1004', '民生银行' => '1006', '兴业银行' => '1009', '平安银行' => '1010',
50
-		'中信银行' => '1021', '华夏银行' => '1025', '广发银行' => '1027', '光大银行' => '1022', '北京银行' => '1032', '宁波银行' => '1056',];
50
+		'中信银行' => '1021', '华夏银行' => '1025', '广发银行' => '1027', '光大银行' => '1022', '北京银行' => '1032', '宁波银行' => '1056', ];
51 51
 
52 52
 	public $getSignKeyUrl = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
53 53
 	public $sandbox = false;
@@ -90,34 +90,34 @@  discard block
 block discarded – undo
90 90
 		$this->cacheProvider = new JsonFileCacheProvider();
91 91
 	}
92 92
 
93
-	public function setWechatOAuth($wechatOAuth){
93
+	public function setWechatOAuth($wechatOAuth) {
94 94
 		$this->wechatOAuth = $wechatOAuth;
95 95
 	}
96 96
 
97
-	public function getWechatOAuth(){
98
-		if(!$this->wechatOAuth){
99
-			$this->wechatOAuth = new WechatOAuth($this->config['app_id'],$this->config['app_secret']);
97
+	public function getWechatOAuth() {
98
+		if (!$this->wechatOAuth) {
99
+			$this->wechatOAuth = new WechatOAuth($this->config['app_id'], $this->config['app_secret']);
100 100
 		}
101 101
 		return $this->wechatOAuth;
102 102
 	}
103 103
 
104
-	public function setConfig($config){
104
+	public function setConfig($config) {
105 105
 		$this->config = $config;
106 106
 	}
107 107
 
108
-	public function getConfig(){
108
+	public function getConfig() {
109 109
 		return $this->config;
110 110
 	}
111 111
 
112
-	public function setHttpClient($httpClient){
112
+	public function setHttpClient($httpClient) {
113 113
 		$this->httpClient = $httpClient;
114 114
 	}
115 115
 
116
-	public function setCacheProvider($cacheProvider){
116
+	public function setCacheProvider($cacheProvider) {
117 117
 		$this->cacheProvider = $cacheProvider;
118 118
 	}
119 119
 
120
-	public function getCacheProvider(){
120
+	public function getCacheProvider() {
121 121
 		return $this->cacheProvider;
122 122
 	}
123 123
 
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 	 * @return string
134 134
 	 * @throws \Exception
135 135
 	 */
136
-	public function getPrepayId($body,$out_trade_no,$total_fee,$openid,$spbill_create_ip = null,$ext = null) {
137
-		$data = ($ext && is_array($ext))?$ext:array();
136
+	public function getPrepayId($body, $out_trade_no, $total_fee, $openid, $spbill_create_ip = null, $ext = null) {
137
+		$data = ($ext && is_array($ext)) ? $ext : array();
138 138
 		$data["body"]         = $body;
139 139
 		$data["out_trade_no"] = $out_trade_no;
140 140
 		$data["total_fee"]    = $total_fee;
141
-		$data["spbill_create_ip"] = $spbill_create_ip?:$_SERVER["REMOTE_ADDR"];
141
+		$data["spbill_create_ip"] = $spbill_create_ip ?: $_SERVER["REMOTE_ADDR"];
142 142
 		$data["notify_url"]   = $this->config["notify_url"];
143 143
 		$data["trade_type"]   = WechatPay::TRADETYPE_JSAPI;
144
-		if(!$openid) throw new Exception('openid is required when trade_type is JSAPI');
145
-		$data["openid"]   = $openid;
144
+		if (!$openid) throw new Exception('openid is required when trade_type is JSAPI');
145
+		$data["openid"] = $openid;
146 146
 		$result = $this->unifiedOrder($data);
147 147
 		return $result["prepay_id"];
148 148
 	}
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * @param $ext array
158 158
 	 * @return string
159 159
 	 */
160
-	public function getPrepayIdAPP($body,$out_trade_no,$total_fee,$spbill_create_ip,$ext = null) {
161
-		$data = ($ext && is_array($ext))?$ext:array();
160
+	public function getPrepayIdAPP($body, $out_trade_no, $total_fee, $spbill_create_ip, $ext = null) {
161
+		$data = ($ext && is_array($ext)) ? $ext : array();
162 162
 		$data["body"]         = $body;
163 163
 		$data["out_trade_no"] = $out_trade_no;
164 164
 		$data["total_fee"]    = $total_fee;
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 	 * @return string
182 182
 	 * @throws Exception
183 183
 	 */
184
-	public function getCodeUrl($body,$out_trade_no,$total_fee,$product_id,$spbill_create_ip = null,$ext = null){
185
-		$data = ($ext && is_array($ext))?$ext:array();
184
+	public function getCodeUrl($body, $out_trade_no, $total_fee, $product_id, $spbill_create_ip = null, $ext = null) {
185
+		$data = ($ext && is_array($ext)) ? $ext : array();
186 186
 		$data["body"]         = $body;
187 187
 		$data["out_trade_no"] = $out_trade_no;
188 188
 		$data["total_fee"]    = $total_fee;
189
-		$data["spbill_create_ip"] = $spbill_create_ip?:$_SERVER["SERVER_ADDR"];
189
+		$data["spbill_create_ip"] = $spbill_create_ip ?: $_SERVER["SERVER_ADDR"];
190 190
 		$data["notify_url"]   = $this->config["notify_url"];
191 191
 		$data["trade_type"]   = self::TRADETYPE_NATIVE;
192
-		if(!$product_id) throw new Exception('product_id is required when trade_type is NATIVE');
192
+		if (!$product_id) throw new Exception('product_id is required when trade_type is NATIVE');
193 193
 		$data["product_id"]   = $product_id;
194 194
 		$result = $this->unifiedOrder($data);
195 195
 		return $result["code_url"];
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 	 * @return string
206 206
 	 * @throws Exception
207 207
 	 */
208
-	public function getMwebUrl($body,$out_trade_no,$total_fee,$ext = null){
209
-		$data = ($ext && is_array($ext))?$ext:array();
208
+	public function getMwebUrl($body, $out_trade_no, $total_fee, $ext = null) {
209
+		$data = ($ext && is_array($ext)) ? $ext : array();
210 210
 		$data["body"]         = $body;
211 211
 		$data["out_trade_no"] = $out_trade_no;
212 212
 		$data["total_fee"]    = $total_fee;
213
-		$data["spbill_create_ip"] = isset($_SERVER["REMOTE_ADDR"])?$_SERVER["REMOTE_ADDR"]:'';
213
+		$data["spbill_create_ip"] = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : '';
214 214
 		$data["notify_url"]   = $this->config["notify_url"];
215 215
 		$data["trade_type"]   = self::TRADETYPE_MWEB;
216
-		if(!isset($this->config['h5_scene_info'])) throw new Exception('h5_scene_info should be configured');
216
+		if (!isset($this->config['h5_scene_info'])) throw new Exception('h5_scene_info should be configured');
217 217
 		$data["scene_info"]   = json_encode($this->config['h5_scene_info']);
218 218
 		$result = $this->unifiedOrder($data);
219 219
 		return $result["mweb_url"];
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
 	public function unifiedOrder($params) {
230 230
 		$data = array();
231 231
 		$data["appid"] = $this->config["app_id"];
232
-		$data["device_info"] = (isset($params['device_info'])&&trim($params['device_info'])!='')?$params['device_info']:null;
232
+		$data["device_info"] = (isset($params['device_info']) && trim($params['device_info']) != '') ? $params['device_info'] : null;
233 233
 		$data["body"] = $params['body'];
234
-		$data["detail"] = isset($params['detail'])?$params['detail']:null;//optional
235
-		$data["attach"] = isset($params['attach'])?$params['attach']:null;//optional
236
-		$data["out_trade_no"] = isset($params['out_trade_no'])?$params['out_trade_no']:null;
237
-		$data["fee_type"] = isset($params['fee_type'])?$params['fee_type']:'CNY';
234
+		$data["detail"] = isset($params['detail']) ? $params['detail'] : null; //optional
235
+		$data["attach"] = isset($params['attach']) ? $params['attach'] : null; //optional
236
+		$data["out_trade_no"] = isset($params['out_trade_no']) ? $params['out_trade_no'] : null;
237
+		$data["fee_type"] = isset($params['fee_type']) ? $params['fee_type'] : 'CNY';
238 238
 		$data["total_fee"]    = $params['total_fee'];
239 239
 		$data["spbill_create_ip"] = $params['spbill_create_ip'];
240
-		$data["time_start"] = isset($params['time_start'])?$params['time_start']:null;//optional
241
-		$data["time_expire"] = isset($params['time_expire'])?$params['time_expire']:null;//optional
242
-		$data["goods_tag"] = isset($params['goods_tag'])?$params['goods_tag']:null;
240
+		$data["time_start"] = isset($params['time_start']) ? $params['time_start'] : null; //optional
241
+		$data["time_expire"] = isset($params['time_expire']) ? $params['time_expire'] : null; //optional
242
+		$data["goods_tag"] = isset($params['goods_tag']) ? $params['goods_tag'] : null;
243 243
 		$data["notify_url"] = $this->config["notify_url"];
244 244
 		$data["trade_type"] = $params['trade_type'];
245
-		if($params['trade_type'] == WechatPay::TRADETYPE_NATIVE){
246
-			if(!isset($params['product_id'])) throw new Exception('product_id is required when trade_type is NATIVE');
245
+		if ($params['trade_type'] == WechatPay::TRADETYPE_NATIVE) {
246
+			if (!isset($params['product_id'])) throw new Exception('product_id is required when trade_type is NATIVE');
247 247
 			$data["product_id"] = $params['product_id'];
248 248
 		}
249
-		if($params['trade_type'] == WechatPay::TRADETYPE_JSAPI){
250
-			if(!isset($params['openid'])) throw new Exception('openid is required when trade_type is JSAPI');
249
+		if ($params['trade_type'] == WechatPay::TRADETYPE_JSAPI) {
250
+			if (!isset($params['openid'])) throw new Exception('openid is required when trade_type is JSAPI');
251 251
 			$data["openid"] = $params['openid'];
252 252
 		}
253 253
 		$result = $this->post(self::URL_UNIFIEDORDER, $data);
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @param $transaction_id string 微信订单号
261 261
 	 * @return array
262 262
 	 */
263
-	public function queryOrderByTransactionId($transaction_id){
263
+	public function queryOrderByTransactionId($transaction_id) {
264 264
 		$data = array();
265 265
 		$data["appid"] = $this->config["app_id"];
266 266
 		$data["transaction_id"] = $transaction_id;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @param $out_trade_no string 商户订单号
275 275
 	 * @return array
276 276
 	 */
277
-	public function queryOrderByOutTradeNo($out_trade_no){
277
+	public function queryOrderByOutTradeNo($out_trade_no) {
278 278
 		$data = array();
279 279
 		$data["appid"] = $this->config["app_id"];
280 280
 		$data["out_trade_no"] = $out_trade_no;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @param $offset int 偏移
290 290
 	 * @return array
291 291
 	 */
292
-	public function queryRefundByTransactionId($transaction_id,$offset = 0){
292
+	public function queryRefundByTransactionId($transaction_id, $offset = 0) {
293 293
 		$data = array();
294 294
 		$data["appid"] = $this->config["app_id"];
295 295
 		$data["transaction_id"] = $transaction_id;
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 * @param $offset int 偏移
306 306
 	 * @return array
307 307
 	 */
308
-	public function queryRefundByOutTradeNo($out_trade_no,$offset = 0){
308
+	public function queryRefundByOutTradeNo($out_trade_no, $offset = 0) {
309 309
 		$data = array();
310 310
 		$data["appid"] = $this->config["app_id"];
311 311
 		$data["out_trade_no"] = $out_trade_no;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 * @param $offset int 偏移
322 322
 	 * @return array
323 323
 	 */
324
-	public function queryRefundByRefundId($refund_id,$offset = 0){
324
+	public function queryRefundByRefundId($refund_id, $offset = 0) {
325 325
 		$data = array();
326 326
 		$data["appid"] = $this->config["app_id"];
327 327
 		$data["refund_id"] = $refund_id;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @param $offset int 偏移
338 338
 	 * @return array
339 339
 	 */
340
-	public function queryRefundByOutRefundNo($out_refund_no,$offset = 0){
340
+	public function queryRefundByOutRefundNo($out_refund_no, $offset = 0) {
341 341
 		$data = array();
342 342
 		$data["appid"] = $this->config["app_id"];
343 343
 		$data["out_refund_no"] = $out_refund_no;
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
 	 * @param $out_trade_no string 商户订单号
353 353
 	 * @return array
354 354
 	 */
355
-	public function closeOrder($out_trade_no){
355
+	public function closeOrder($out_trade_no) {
356 356
 		$data = array();
357 357
 		$data["appid"] = $this->config["app_id"];
358 358
 		$data["out_trade_no"] = $out_trade_no;
359
-		$result = $this->post(self::URL_CLOSEORDER, $data,false);
359
+		$result = $this->post(self::URL_CLOSEORDER, $data, false);
360 360
 		return $result;
361 361
 	}
362 362
 
@@ -371,14 +371,14 @@  discard block
 block discarded – undo
371 371
 	 * @param $ext array 扩展数组
372 372
 	 * @return array
373 373
 	 */
374
-	public function refundByOutTradeNo($out_trade_no,$out_refund_no,$total_fee,$refund_fee,$ext = array()){
375
-		$data = ($ext && is_array($ext))?$ext:array();
374
+	public function refundByOutTradeNo($out_trade_no, $out_refund_no, $total_fee, $refund_fee, $ext = array()) {
375
+		$data = ($ext && is_array($ext)) ? $ext : array();
376 376
 		$data["appid"] = $this->config["app_id"];
377 377
 		$data["out_trade_no"] = $out_trade_no;
378 378
 		$data["out_refund_no"] = $out_refund_no;
379 379
 		$data["total_fee"] = $total_fee;
380 380
 		$data["refund_fee"] = $refund_fee;
381
-		$result = $this->post(self::URL_REFUND, $data,true);
381
+		$result = $this->post(self::URL_REFUND, $data, true);
382 382
 		return $result;
383 383
 	}
384 384
 
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 	 * @param $ext array 扩展数组
394 394
 	 * @return array
395 395
 	 */
396
-	public function refundByTransactionId($transaction_id,$out_refund_no,$total_fee,$refund_fee,$ext = array()){
397
-		$data = ($ext && is_array($ext))?$ext:array();
396
+	public function refundByTransactionId($transaction_id, $out_refund_no, $total_fee, $refund_fee, $ext = array()) {
397
+		$data = ($ext && is_array($ext)) ? $ext : array();
398 398
 		$data["appid"] = $this->config["app_id"];
399 399
 		$data["transaction_id"] = $transaction_id;
400 400
 		$data["out_refund_no"] = $out_refund_no;
401 401
 		$data["total_fee"] = $total_fee;
402 402
 		$data["refund_fee"] = $refund_fee;
403
-		$result = $this->post(self::URL_REFUND, $data,true);
403
+		$result = $this->post(self::URL_REFUND, $data, true);
404 404
 		return $result;
405 405
 	}
406 406
 
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
 	 * @param $out_trade_no string 商户订单号
411 411
 	 * @return array
412 412
 	 */
413
-	public function reverseByOutTradeNo($out_trade_no){
413
+	public function reverseByOutTradeNo($out_trade_no) {
414 414
 		$data = array();
415 415
 		$data["appid"] = $this->config["app_id"];
416 416
 		$data["out_trade_no"] = $out_trade_no;
417
-		$result = $this->post(self::URL_REVERSE, $data,true);
417
+		$result = $this->post(self::URL_REVERSE, $data, true);
418 418
 		return $result;
419 419
 	}
420 420
 
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 	 * @param $transaction_id string 微信订单号
425 425
 	 * @return array
426 426
 	 */
427
-	public function reverseByTransactionId($transaction_id){
427
+	public function reverseByTransactionId($transaction_id) {
428 428
 		$data = array();
429 429
 		$data["appid"] = $this->config["app_id"];
430 430
 		$data["transaction_id"] = $transaction_id;
431
-		$result = $this->post(self::URL_REVERSE, $data,true);
431
+		$result = $this->post(self::URL_REVERSE, $data, true);
432 432
 		return $result;
433 433
 	}
434 434
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 * @param $bill_type string 类型 ALL|SUCCESS
440 440
 	 * @return array
441 441
 	 */
442
-	public function downloadBill($bill_date,$bill_type = 'ALL'){
442
+	public function downloadBill($bill_date, $bill_type = 'ALL') {
443 443
 		$data = array();
444 444
 		$data["appid"] = $this->config["app_id"];
445 445
 		$data["bill_date"] = $bill_date;
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	 * @param $tar_type string 压缩账单
457 457
 	 * @return array
458 458
 	 */
459
-	public function downloadFundFlow($bill_date,$account_type = self::ACCOUNTTYPE_BASIC,$tar_type = 'GZIP'){
459
+	public function downloadFundFlow($bill_date, $account_type = self::ACCOUNTTYPE_BASIC, $tar_type = 'GZIP') {
460 460
 		$data = array();
461 461
 		$data["appid"] = $this->config["app_id"];
462 462
 		$data["bill_date"] = $bill_date;
@@ -483,14 +483,14 @@  discard block
 block discarded – undo
483 483
 	 * @return array
484 484
 	 * @throws Exception
485 485
 	 */
486
-	public function sendRedPack($mch_billno,$send_name,$re_openid,$total_amount,$total_num,$wishing,$act_name,$remark,$scene_id = '',$riskinfo = '',$consume_mch_id = ''){
486
+	public function sendRedPack($mch_billno, $send_name, $re_openid, $total_amount, $total_num, $wishing, $act_name, $remark, $scene_id = '', $riskinfo = '', $consume_mch_id = '') {
487 487
 		$data = array();
488 488
 		$data["wxappid"] = $this->config["app_id"];
489 489
 		$data["mch_billno"] = $mch_billno;
490 490
 		$data["send_name"] = $send_name;
491 491
 		$data["re_openid"] = $re_openid;
492 492
 		$data["total_amount"] = $total_amount;
493
-		if($total_amount > 20000 && trim($scene_id)=='') throw new Exception("scene_id is required when total_amount beyond 20000");
493
+		if ($total_amount > 20000 && trim($scene_id) == '') throw new Exception("scene_id is required when total_amount beyond 20000");
494 494
 		$data["total_num"] = $total_num;
495 495
 		$data["wishing"] = $wishing;
496 496
 		$data["act_name"] = $act_name;
@@ -519,14 +519,14 @@  discard block
 block discarded – undo
519 519
 	 * @return array
520 520
 	 * @throws Exception
521 521
 	 */
522
-	public function sendGroupRedPack($mch_billno,$send_name,$re_openid,$total_amount,$total_num,$wishing,$act_name,$remark,$scene_id = '',$riskinfo = '',$consume_mch_id = ''){
522
+	public function sendGroupRedPack($mch_billno, $send_name, $re_openid, $total_amount, $total_num, $wishing, $act_name, $remark, $scene_id = '', $riskinfo = '', $consume_mch_id = '') {
523 523
 		$data = array();
524
-		$data["wxappid"] = $this->config["app_id"];//NOTE: WXappid
524
+		$data["wxappid"] = $this->config["app_id"]; //NOTE: WXappid
525 525
 		$data["mch_billno"] = $mch_billno;
526 526
 		$data["send_name"] = $send_name;
527 527
 		$data["re_openid"] = $re_openid;
528 528
 		$data["total_amount"] = $total_amount;
529
-		if($total_amount > 20000 && trim($scene_id)=='') throw new Exception("scene_id is required when total_amount beyond 20000(200rmb)");
529
+		if ($total_amount > 20000 && trim($scene_id) == '') throw new Exception("scene_id is required when total_amount beyond 20000(200rmb)");
530 530
 		$data["total_num"] = $total_num;
531 531
 		$data["amt_type"] = 'ALL_RAND'; //红包金额设置方式 ALL_RAND—全部随机
532 532
 		$data["wishing"] = $wishing;
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	 * @throws Exception
547 547
 	 * @ref https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_6&index=5
548 548
 	 */
549
-	public function getHbInfo($mch_billno){
549
+	public function getHbInfo($mch_billno) {
550 550
 		$data = array();
551 551
 		$data["mch_billno"] = $mch_billno;
552 552
 		$data["appid"] = $this->config["app_id"];
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
 	 * @param int $limit 条数
565 565
 	 * @return array
566 566
 	 */
567
-	public function batchQueryComment($begin_time,$end_time,$offset = 0,$limit = 200){
567
+	public function batchQueryComment($begin_time, $end_time, $offset = 0, $limit = 200) {
568 568
 		$data = array();
569 569
 		$data["appid"] = $this->config["app_id"];
570 570
 		$data["begin_time"] = $begin_time;
571 571
 		$data["end_time"] = $end_time;
572 572
 		$data["offset"] = $offset;
573 573
 		$data["limit"] = $limit;
574
-		$data["sign"] = $this->sign($data,WechatPay::SIGNTYPE_HMACSHA256);
574
+		$data["sign"] = $this->sign($data, WechatPay::SIGNTYPE_HMACSHA256);
575 575
 		$result = $this->post(self::URL_BATCHQUERYCOMMENT, $data, true); //cert is required
576 576
 		return $result;
577 577
 	}
@@ -584,21 +584,21 @@  discard block
 block discarded – undo
584 584
 	 */
585 585
 	public function getPackage($prepay_id, $trade_type = WechatPay::TRADETYPE_JSAPI) {
586 586
 		$data = array();
587
-		if ($trade_type == WechatPay::TRADETYPE_JSAPI){
587
+		if ($trade_type == WechatPay::TRADETYPE_JSAPI) {
588 588
 			$data["package"]   = "prepay_id=$prepay_id";
589 589
 			$data["timeStamp"] = time();
590 590
 			$data["nonceStr"]  = $this->getNonceStr();
591 591
 			$data["appId"] = $this->config["app_id"];
592 592
 			$data["signType"]  = "MD5";
593 593
 			$data["paySign"]   = $this->sign($data);
594
-		} else if ($trade_type == WechatPay::TRADETYPE_APP){
594
+		}else if ($trade_type == WechatPay::TRADETYPE_APP) {
595 595
 			$data["package"]   = "Sign=WXPay";
596 596
 			$data['prepayid'] = $prepay_id;
597 597
 			$data['partnerid'] = $this->config["mch_id"];
598 598
 			$data["timestamp"] = time();
599 599
 			$data["noncestr"]  = $this->getNonceStr();
600 600
 			$data["appid"] = $this->config["app_id"];
601
-			$data["sign"]   = $this->sign($data);
601
+			$data["sign"] = $this->sign($data);
602 602
 		}
603 603
 		return $data;
604 604
 	}
@@ -614,15 +614,15 @@  discard block
 block discarded – undo
614 614
 	 * @param array $ext
615 615
 	 * @return array
616 616
 	 */
617
-	public function microPay($body,$out_trade_no,$total_fee,$spbill_create_ip,$auth_code,$ext = array()){
618
-		$data = (!empty($ext) && is_array($ext))?$ext:array();
617
+	public function microPay($body, $out_trade_no, $total_fee, $spbill_create_ip, $auth_code, $ext = array()) {
618
+		$data = (!empty($ext) && is_array($ext)) ? $ext : array();
619 619
 		$data["appid"] = $this->config["app_id"];
620 620
 		$data["body"]         = $body;
621 621
 		$data["out_trade_no"] = $out_trade_no;
622 622
 		$data["total_fee"]    = $total_fee;
623 623
 		$data["spbill_create_ip"] = $spbill_create_ip;
624 624
 		$data["auth_code"] = $auth_code;
625
-		$result = $this->post(self::URL_MICROPAY,$data,false);
625
+		$result = $this->post(self::URL_MICROPAY, $data, false);
626 626
 		return $result;
627 627
 	}
628 628
 
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
 	 * @return null
634 634
 	 * @throws Exception
635 635
 	 */
636
-	public function onPaidNotify($notify_data,callable $callback = null){
637
-		if(!is_array($notify_data)) $notify_data = $this->xml2array($notify_data);
638
-		if(!$this->validateSign($notify_data)) throw new Exception('Invalid paid notify data');
639
-		if($callback && is_callable($callback)){
640
-			return call_user_func_array( $callback , [$notify_data] );
636
+	public function onPaidNotify($notify_data, callable $callback = null) {
637
+		if (!is_array($notify_data)) $notify_data = $this->xml2array($notify_data);
638
+		if (!$this->validateSign($notify_data)) throw new Exception('Invalid paid notify data');
639
+		if ($callback && is_callable($callback)) {
640
+			return call_user_func_array($callback, [$notify_data]);
641 641
 		}
642 642
 	}
643 643
 
@@ -648,11 +648,11 @@  discard block
 block discarded – undo
648 648
 	 * @return mixed
649 649
 	 * @throws Exception
650 650
 	 */
651
-	public function onRefundedNotify($notify_data,callable $callback = null){
652
-		if(!is_array($notify_data)) $notify_data = $this->xml2array($notify_data);
653
-		if(!$this->validateSign($notify_data)) throw new Exception('Invalid refund notify data');
654
-		if($callback && is_callable($callback)){
655
-			return call_user_func_array( $callback ,[$notify_data] );
651
+	public function onRefundedNotify($notify_data, callable $callback = null) {
652
+		if (!is_array($notify_data)) $notify_data = $this->xml2array($notify_data);
653
+		if (!$this->validateSign($notify_data)) throw new Exception('Invalid refund notify data');
654
+		if ($callback && is_callable($callback)) {
655
+			return call_user_func_array($callback, [$notify_data]);
656 656
 		}
657 657
 	}
658 658
 
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	 * @param bool $print
679 679
 	 * @return string
680 680
 	 */
681
-	public function responseNotify($print = true,$data = [],$return_code="SUCCESS", $return_msg= 'OK') {
681
+	public function responseNotify($print = true, $data = [], $return_code = "SUCCESS", $return_msg = 'OK') {
682 682
 		$data["return_code"] = $return_code;
683 683
 		if ($return_msg) {
684 684
 			$data["return_msg"] = $return_msg;
685 685
 		}
686 686
 		$xml = $this->array2xml($data);
687
-		if($print === true) print $xml;
687
+		if ($print === true) print $xml;
688 688
 		else return $xml;
689 689
 	}
690 690
 
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 	 * @param string $err_code_des
705 705
 	 * @return array
706 706
 	 */
707
-	public function report($interface_url,$execution_time,$return_code,$result_code,$user_ip,$out_trade_no = null,$time = null,$device_info = null,
708
-	                       $return_msg = null,$err_code = null,$err_code_des = null){
707
+	public function report($interface_url, $execution_time, $return_code, $result_code, $user_ip, $out_trade_no = null, $time = null, $device_info = null,
708
+	                       $return_msg = null, $err_code = null, $err_code_des = null) {
709 709
 		$data = array();
710 710
 		$data["appid"] = $this->config["app_id"];
711 711
 		$data["interface_url"] = $interface_url;
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
 		$data["return_code"] = $return_code;
714 714
 		$data["result_code"] = $result_code;
715 715
 		$data["user_ip"] = $user_ip;
716
-		if($out_trade_no) $data["out_trade_no"] = $out_trade_no;
717
-		if($time) $data["time"] = $time;
718
-		if($device_info) $data["device_info"] = $device_info;
719
-		if($return_msg) $data["return_msg"] = $return_msg;
720
-		if($err_code) $data["err_code"] = $err_code;
721
-		if($err_code_des) $data["err_code_des"] = $err_code_des;
716
+		if ($out_trade_no) $data["out_trade_no"] = $out_trade_no;
717
+		if ($time) $data["time"] = $time;
718
+		if ($device_info) $data["device_info"] = $device_info;
719
+		if ($return_msg) $data["return_msg"] = $return_msg;
720
+		if ($err_code) $data["err_code"] = $err_code;
721
+		if ($err_code_des) $data["err_code_des"] = $err_code_des;
722 722
 		$result = $this->post(self::URL_REPORT, $data, false);
723 723
 		return $result;
724 724
 	}
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 	 * @param $longurl
730 730
 	 * @return string
731 731
 	 */
732
-	public function shortUrl($longurl){
732
+	public function shortUrl($longurl) {
733 733
 		$data = array();
734 734
 		$data["appid"] = $this->config["app_id"];
735 735
 		$data["long_url"] = $longurl;
736
-		$result = $this->post(self::URL_SHORTURL,$data,false);
736
+		$result = $this->post(self::URL_SHORTURL, $data, false);
737 737
 		return $result['short_url'];
738 738
 	}
739 739
 
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
 	 * @param $auth_code
744 744
 	 * @return mixed
745 745
 	 */
746
-	public function authCodeToOpenId($auth_code){
746
+	public function authCodeToOpenId($auth_code) {
747 747
 		$data = array();
748 748
 		$data["appid"] = $this->config["app_id"];
749 749
 		$data["auth_code"] = $auth_code;
750
-		$result = $this->post(self::URL_AUTHCODETOOPENID,$data,false);
750
+		$result = $this->post(self::URL_AUTHCODETOOPENID, $data, false);
751 751
 		return $result['openid'];
752 752
 	}
753 753
 
@@ -764,19 +764,19 @@  discard block
 block discarded – undo
764 764
 	 * @return array
765 765
 	 * @throws Exception
766 766
 	 */
767
-	public function transferWallet($partner_trade_no,$openid,$amount,$desc,$spbill_create_ip = null,$re_user_name = null,$check_name = WechatPay::CHECKNAME_FORCECHECK){
767
+	public function transferWallet($partner_trade_no, $openid, $amount, $desc, $spbill_create_ip = null, $re_user_name = null, $check_name = WechatPay::CHECKNAME_FORCECHECK) {
768 768
 		$data = array();
769
-		if($check_name == WechatPay::CHECKNAME_FORCECHECK && !$re_user_name) throw new Exception('Real name is required');
769
+		if ($check_name == WechatPay::CHECKNAME_FORCECHECK && !$re_user_name) throw new Exception('Real name is required');
770 770
 		$data["mch_appid"] = $this->config["app_id"];
771 771
 		$data["mchid"] = $this->config["mch_id"];
772 772
 		$data["partner_trade_no"] = $partner_trade_no;
773 773
 		$data["openid"] = $openid;
774 774
 		$data["amount"] = $amount;
775 775
 		$data["desc"] = $desc;
776
-		$data['spbill_create_ip'] = $spbill_create_ip?:$_SERVER['SERVER_ADDR'];
776
+		$data['spbill_create_ip'] = $spbill_create_ip ?: $_SERVER['SERVER_ADDR'];
777 777
 		$data["check_name"] = $check_name;
778 778
 		$data["re_user_name"] = $re_user_name;
779
-		$result = $this->post(self::URL_TRANSFER_WALLET,$data,true);
779
+		$result = $this->post(self::URL_TRANSFER_WALLET, $data, true);
780 780
 		return $result;
781 781
 	}
782 782
 
@@ -786,12 +786,12 @@  discard block
 block discarded – undo
786 786
 	 * @param $partner_trade_no
787 787
 	 * @return array
788 788
 	 */
789
-	public function queryTransferWallet($partner_trade_no){
789
+	public function queryTransferWallet($partner_trade_no) {
790 790
 		$data = array();
791 791
 		$data["appid"] = $this->config["app_id"];
792 792
 		$data["mch_id"] = $this->config["mch_id"];
793 793
 		$data["partner_trade_no"] = $partner_trade_no;
794
-		$result = $this->post(self::URL_QUERY_TRANSFER_WALLET,$data,true);
794
+		$result = $this->post(self::URL_QUERY_TRANSFER_WALLET, $data, true);
795 795
 		return $result;
796 796
 	}
797 797
 
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 	 * @return array
808 808
 	 * @throws Exception
809 809
 	 */
810
-	public function transferBankCard($partner_trade_no,$bank_no,$true_name,$bank_code,$amount,$desc){
811
-		if(!in_array($bank_code,array_values(self::$BANKCODE))) throw new Exception("Unsupported bank code: $bank_code");
810
+	public function transferBankCard($partner_trade_no, $bank_no, $true_name, $bank_code, $amount, $desc) {
811
+		if (!in_array($bank_code, array_values(self::$BANKCODE))) throw new Exception("Unsupported bank code: $bank_code");
812 812
 		$data = array();
813 813
 		$data["partner_trade_no"] = $partner_trade_no;
814 814
 		$enc_bank_no = $this->rsaEncrypt($bank_no);
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 		$data["bank_code"] = $bank_code;
819 819
 		$data["desc"] = $desc;
820 820
 		$data["amount"] = $amount;
821
-		$result = $this->post(self::URL_TRANSFER_BANKCARD,$data,true);
821
+		$result = $this->post(self::URL_TRANSFER_BANKCARD, $data, true);
822 822
 		return $result;
823 823
 	}
824 824
 
@@ -828,12 +828,12 @@  discard block
 block discarded – undo
828 828
 	 * @param $partner_trade_no
829 829
 	 * @return array
830 830
 	 */
831
-	public function queryTransferBankCard($partner_trade_no){
831
+	public function queryTransferBankCard($partner_trade_no) {
832 832
 		$data = array();
833 833
 		$data["appid"] = $this->config["app_id"];
834 834
 		$data["mch_id"] = $this->config["mch_id"];
835 835
 		$data["partner_trade_no"] = $partner_trade_no;
836
-		$result = $this->post(self::URL_QUERY_TRANSFER_WALLET,$data,true);
836
+		$result = $this->post(self::URL_QUERY_TRANSFER_WALLET, $data, true);
837 837
 		return $result;
838 838
 	}
839 839
 
@@ -847,14 +847,14 @@  discard block
 block discarded – undo
847 847
 	 * @param array $ext
848 848
 	 * @return array
849 849
 	 */
850
-	public function sendCoupon($coupon_stock_id,$open_id,$partner_trade_no,$op_user_id = '',$ext = array()){
851
-		$data = (!empty($ext) && is_array($ext))?$ext:array();
850
+	public function sendCoupon($coupon_stock_id, $open_id, $partner_trade_no, $op_user_id = '', $ext = array()) {
851
+		$data = (!empty($ext) && is_array($ext)) ? $ext : array();
852 852
 		$data["partner_trade_no"] = $partner_trade_no;
853 853
 		$data["coupon_stock_id"] = $coupon_stock_id;
854 854
 		$data["openid_count"] = 1;
855 855
 		$data["open_id"] = $open_id;
856 856
 		$data["op_user_id"] = $op_user_id;
857
-		$result = $this->post(self::URL_SEND_COUPON,$data,true);
857
+		$result = $this->post(self::URL_SEND_COUPON, $data, true);
858 858
 		return $result;
859 859
 	}
860 860
 
@@ -865,11 +865,11 @@  discard block
 block discarded – undo
865 865
 	 * @param string $op_user_id
866 866
 	 * @return array
867 867
 	 */
868
-	public function queryCouponStock($coupon_stock_id,$op_user_id = ''){
868
+	public function queryCouponStock($coupon_stock_id, $op_user_id = '') {
869 869
 		$data = array();
870 870
 		$data["coupon_stock_id"] = $coupon_stock_id;
871 871
 		$data["op_user_id"] = $op_user_id;
872
-		$result = $this->post(self::URL_QUERY_COUPON_STOCK,$data,false);
872
+		$result = $this->post(self::URL_QUERY_COUPON_STOCK, $data, false);
873 873
 		return $result;
874 874
 	}
875 875
 
@@ -883,13 +883,13 @@  discard block
 block discarded – undo
883 883
 	 * @param array $ext
884 884
 	 * @return array
885 885
 	 */
886
-	public function queryCouponsInfo($coupon_id,$open_id,$stock_id,$op_user_id = '',$ext = array()){
887
-		$data = (!empty($ext) && is_array($ext))?$ext:array();
886
+	public function queryCouponsInfo($coupon_id, $open_id, $stock_id, $op_user_id = '', $ext = array()) {
887
+		$data = (!empty($ext) && is_array($ext)) ? $ext : array();
888 888
 		$data["coupon_id"] = $coupon_id;
889 889
 		$data["stock_id"] = $stock_id;
890 890
 		$data["open_id"] = $open_id;
891 891
 		$data["op_user_id"] = $op_user_id;
892
-		$result = $this->post(self::URL_QUERY_COUPON_INFO,$data,false);
892
+		$result = $this->post(self::URL_QUERY_COUPON_INFO, $data, false);
893 893
 		return $result;
894 894
 	}
895 895
 
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 	 * @return string
901 901
 	 * @throws Exception
902 902
 	 */
903
-	public function getPublicKey($refresh = false){
904
-		if(!$this->publicKey) {
903
+	public function getPublicKey($refresh = false) {
904
+		if (!$this->publicKey) {
905 905
 			if (!$refresh && file_exists($this->config["rsa_pubkey_path"])) {
906 906
 				$this->publicKey = file_get_contents($this->config["rsa_pubkey_path"]);
907
-			}else{
907
+			}else {
908 908
 				$data = array();
909 909
 				$data["mch_id"] = $this->config["mch_id"];
910 910
 				$data["sign_type"] = $this->config["sign_type"];
@@ -919,24 +919,24 @@  discard block
 block discarded – undo
919 919
 		return $this->publicKey;
920 920
 	}
921 921
 
922
-	public function setPublicKey($publicKey){
922
+	public function setPublicKey($publicKey) {
923 923
 		$this->publicKey = $publicKey;
924 924
 	}
925 925
 
926
-	private function convertPKCS1toPKCS8($pkcs1){
926
+	private function convertPKCS1toPKCS8($pkcs1) {
927 927
 		$start_key = $pkcs1;
928 928
 		$start_key = str_replace('-----BEGIN RSA PUBLIC KEY-----', '', $start_key);
929 929
 		$start_key = trim(str_replace('-----END RSA PUBLIC KEY-----', '', $start_key));
930
-		$key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' . str_replace("\n", '', $start_key);
931
-		$key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($key, 64, "\n", true) . "\n-----END PUBLIC KEY-----";
930
+		$key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A'.str_replace("\n", '', $start_key);
931
+		$key = "-----BEGIN PUBLIC KEY-----\n".wordwrap($key, 64, "\n", true)."\n-----END PUBLIC KEY-----";
932 932
 		return $key;
933 933
 	}
934 934
 
935
-	public function rsaEncrypt($data,$pubkey = null){
936
-		if(!$pubkey) $pubkey = $this->getPublicKey();
935
+	public function rsaEncrypt($data, $pubkey = null) {
936
+		if (!$pubkey) $pubkey = $this->getPublicKey();
937 937
 		$encrypted = null;
938 938
 		$pubkey = openssl_get_publickey($pubkey);
939
-		if (@openssl_public_encrypt($data, $encrypted, $pubkey,OPENSSL_PKCS1_OAEP_PADDING))
939
+		if (@openssl_public_encrypt($data, $encrypted, $pubkey, OPENSSL_PKCS1_OAEP_PADDING))
940 940
 			$data = base64_encode($encrypted);
941 941
 		else
942 942
 			throw new Exception('Unable to encrypt data');
@@ -948,10 +948,10 @@  discard block
 block discarded – undo
948 948
 	 * @ref https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=23_1
949 949
 	 * @return array
950 950
 	 */
951
-	public function getSignKey(){
951
+	public function getSignKey() {
952 952
 		$data = array();
953 953
 		$data["mch_id"] = $this->config["mch_id"];
954
-		$result = $this->post($this->getSignKeyUrl,$data,false);
954
+		$result = $this->post($this->getSignKeyUrl, $data, false);
955 955
 		return $result['sandbox_signkey'];
956 956
 	}
957 957
 
@@ -961,8 +961,8 @@  discard block
 block discarded – undo
961 961
 	 * @param string $ticket
962 962
 	 * @return array
963 963
 	 */
964
-	public function getSignPackage($url, $ticket = null){
965
-		if(!$ticket) $ticket = $this->getTicket();
964
+	public function getSignPackage($url, $ticket = null) {
965
+		if (!$ticket) $ticket = $this->getTicket();
966 966
 		$timestamp = time();
967 967
 		$nonceStr = $this->getNonceStr();
968 968
 		$rawString = "jsapi_ticket=$ticket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
@@ -984,29 +984,29 @@  discard block
 block discarded – undo
984 984
 	 * @param boolean $cache
985 985
 	 * @return string
986 986
 	 */
987
-	public function getTicket($cache = true){
987
+	public function getTicket($cache = true) {
988 988
 		$ticket = null;
989 989
 		$cacheKey = 'jsapi_ticket';
990
-		if($cache === true){
990
+		if ($cache === true) {
991 991
 			$data = $this->cacheProvider->get($cacheKey);
992 992
 			if ($data && $data->expires_at < time()) {
993 993
 				$ticket = $data->ticket;
994 994
 			}
995 995
 		}
996
-		if(!$ticket){
996
+		if (!$ticket) {
997 997
 			$data = $this->getWechatOAuth()->getTicket();
998
-			if($cache === true){
999
-				$this->cacheProvider->set($cacheKey,$data,time() + $data->expires_in);
998
+			if ($cache === true) {
999
+				$this->cacheProvider->set($cacheKey, $data, time() + $data->expires_in);
1000 1000
 			}
1001 1001
 			$ticket = $data->ticket;
1002 1002
 		}
1003 1003
 		return $ticket;
1004 1004
 	}
1005 1005
 
1006
-	private function post($url, $data,$cert = true) {
1007
-		if(!isset($data['mch_id']) && !isset($data['mchid'])) $data["mch_id"] = $this->config["mch_id"];
1008
-		if(!isset($data['nonce_str'])) $data["nonce_str"] = $this->getNonceStr();
1009
-		if(!isset($data['sign'])) $data['sign'] = $this->sign($data);
1006
+	private function post($url, $data, $cert = true) {
1007
+		if (!isset($data['mch_id']) && !isset($data['mchid'])) $data["mch_id"] = $this->config["mch_id"];
1008
+		if (!isset($data['nonce_str'])) $data["nonce_str"] = $this->getNonceStr();
1009
+		if (!isset($data['sign'])) $data['sign'] = $this->sign($data);
1010 1010
 		$this->requestXML = $this->responseXML = null;
1011 1011
 		$this->requestArray = $this->responseArray = null;
1012 1012
 
@@ -1018,26 +1018,26 @@  discard block
 block discarded – undo
1018 1018
 			CURLOPT_RETURNTRANSFER => true,
1019 1019
 			CURLOPT_TIMEOUT => 10
1020 1020
 		];
1021
-		if($cert == true){
1021
+		if ($cert == true) {
1022 1022
 			$opts[CURLOPT_SSLCERTTYPE] = 'PEM';
1023 1023
 			$opts[CURLOPT_SSLCERT] = $this->config['ssl_cert_path'];
1024 1024
 			$opts[CURLOPT_SSLKEYTYPE] = 'PEM';
1025 1025
 			$opts[CURLOPT_SSLKEY] = $this->config['ssl_key_path'];
1026 1026
 		}
1027 1027
 		$processResponse = true;
1028
-		if(in_array($url,[self::URL_DOWNLOADBILL,self::URL_DOWNLOAD_FUND_FLOW,self::URL_BATCHQUERYCOMMENT])){
1028
+		if (in_array($url, [self::URL_DOWNLOADBILL, self::URL_DOWNLOAD_FUND_FLOW, self::URL_BATCHQUERYCOMMENT])) {
1029 1029
 			$processResponse = false;
1030 1030
 		}
1031
-		if($this->sandbox === true){
1031
+		if ($this->sandbox === true) {
1032 1032
 			$host = "https://api.mch.weixin.qq.com";
1033
-			$url = str_replace($host,'',$url);
1033
+			$url = str_replace($host, '', $url);
1034 1034
 			$url = "{$host}/sandboxnew{$url}";
1035 1035
 		}
1036
-		$content = $this->httpClient->post($url,$this->requestXML,[],$opts);
1037
-		if(!$content) throw new Exception("Empty response with {$this->requestXML}");
1036
+		$content = $this->httpClient->post($url, $this->requestXML, [], $opts);
1037
+		if (!$content) throw new Exception("Empty response with {$this->requestXML}");
1038 1038
 
1039 1039
 		$this->responseXML = $content;
1040
-		if($processResponse)
1040
+		if ($processResponse)
1041 1041
 			return $this->processResponseXML($this->responseXML);
1042 1042
 		else return $this->responseXML;
1043 1043
 
@@ -1048,51 +1048,51 @@  discard block
 block discarded – undo
1048 1048
 	 * @return array
1049 1049
 	 * @throws Exception
1050 1050
 	 */
1051
-	private function processResponseXML($responseXML){
1051
+	private function processResponseXML($responseXML) {
1052 1052
 		$result = $this->xml2array($responseXML);
1053 1053
 		$this->responseArray = $result;
1054
-		if(empty($result['return_code'])){
1054
+		if (empty($result['return_code'])) {
1055 1055
 			throw new Exception("No return code presents in {$this->responseXML}");
1056 1056
 		}
1057 1057
 		$this->returnCode = $result["return_code"];
1058
-		$this->returnMsg = isset($result['return_msg'])?$result['return_msg']:'';
1058
+		$this->returnMsg = isset($result['return_msg']) ? $result['return_msg'] : '';
1059 1059
 
1060 1060
 		if ($this->returnCode == "SUCCESS") {
1061
-			if(isset($result['result_code']) && $result['result_code'] == "FAIL"){
1061
+			if (isset($result['result_code']) && $result['result_code'] == "FAIL") {
1062 1062
 				$this->resultCode = $result['result_code'];
1063 1063
 				$this->errCode = $result['err_code'];
1064 1064
 				$this->errCodeDes = $result['err_code_des'];
1065 1065
 				throw new Exception("[$this->errCode]$this->errCodeDes");
1066
-			}else{
1066
+			}else {
1067 1067
 				return $result;
1068 1068
 			}
1069
-		} else if($this->returnCode == 'FAIL'){
1069
+		}else if ($this->returnCode == 'FAIL') {
1070 1070
 			throw new Exception($this->returnMsg);
1071 1071
 		}
1072 1072
 	}
1073 1073
 
1074
-	public function sign($data,$sign_type = WechatPay::SIGNTYPE_MD5) {
1074
+	public function sign($data, $sign_type = WechatPay::SIGNTYPE_MD5) {
1075 1075
 		ksort($data);
1076 1076
 		$string1 = "";
1077 1077
 		foreach ($data as $k => $v) {
1078
-			if ($v && trim($v)!='') {
1078
+			if ($v && trim($v) != '') {
1079 1079
 				$string1 .= "$k=$v&";
1080 1080
 			}
1081 1081
 		}
1082
-		$stringSignTemp = $string1 . "key=" . $this->config["api_key"];
1083
-		if($sign_type == WechatPay::SIGNTYPE_MD5){
1082
+		$stringSignTemp = $string1."key=".$this->config["api_key"];
1083
+		if ($sign_type == WechatPay::SIGNTYPE_MD5) {
1084 1084
 			$sign = strtoupper(md5($stringSignTemp));
1085
-		}elseif($sign_type == WechatPay::SIGNTYPE_HMACSHA256){
1086
-			$sign = strtoupper(hash_hmac('sha256',$stringSignTemp,$this->config["api_key"]));
1085
+		}elseif ($sign_type == WechatPay::SIGNTYPE_HMACSHA256) {
1086
+			$sign = strtoupper(hash_hmac('sha256', $stringSignTemp, $this->config["api_key"]));
1087 1087
 		}else throw new Exception("Not supported sign type - $sign_type");
1088 1088
 		return $sign;
1089 1089
 	}
1090 1090
 
1091 1091
 	private function array2xml($array) {
1092
-		$xml = "<xml>" . PHP_EOL;
1092
+		$xml = "<xml>".PHP_EOL;
1093 1093
 		foreach ($array as $k => $v) {
1094
-			if($v && trim($v)!='')
1095
-				$xml .= "<$k><![CDATA[$v]]></$k>" . PHP_EOL;
1094
+			if ($v && trim($v) != '')
1095
+				$xml .= "<$k><![CDATA[$v]]></$k>".PHP_EOL;
1096 1096
 		}
1097 1097
 		$xml .= "</xml>";
1098 1098
 		return $xml;
@@ -1101,19 +1101,19 @@  discard block
 block discarded – undo
1101 1101
 	private function xml2array($xml) {
1102 1102
 		$array = array();
1103 1103
 		$tmp = null;
1104
-		try{
1104
+		try {
1105 1105
 			$tmp = (array) simplexml_load_string($xml);
1106
-		}catch(Exception $e){
1106
+		} catch (Exception $e) {
1107 1107
 			throw $e;
1108 1108
 		}
1109
-		foreach ( $tmp as $k => $v) {
1109
+		foreach ($tmp as $k => $v) {
1110 1110
 			$array[$k] = (string) $v;
1111 1111
 		}
1112 1112
 		return $array;
1113 1113
 	}
1114 1114
 
1115 1115
 	private function getNonceStr() {
1116
-		return substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"),0,32);
1116
+		return substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 32);
1117 1117
 	}
1118 1118
 
1119 1119
 }
1120 1120
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +100 added lines, -41 removed lines patch added patch discarded remove patch
@@ -141,7 +141,9 @@  discard block
 block discarded – undo
141 141
 		$data["spbill_create_ip"] = $spbill_create_ip?:$_SERVER["REMOTE_ADDR"];
142 142
 		$data["notify_url"]   = $this->config["notify_url"];
143 143
 		$data["trade_type"]   = WechatPay::TRADETYPE_JSAPI;
144
-		if(!$openid) throw new Exception('openid is required when trade_type is JSAPI');
144
+		if(!$openid) {
145
+			throw new Exception('openid is required when trade_type is JSAPI');
146
+		}
145 147
 		$data["openid"]   = $openid;
146 148
 		$result = $this->unifiedOrder($data);
147 149
 		return $result["prepay_id"];
@@ -189,7 +191,9 @@  discard block
 block discarded – undo
189 191
 		$data["spbill_create_ip"] = $spbill_create_ip?:$_SERVER["SERVER_ADDR"];
190 192
 		$data["notify_url"]   = $this->config["notify_url"];
191 193
 		$data["trade_type"]   = self::TRADETYPE_NATIVE;
192
-		if(!$product_id) throw new Exception('product_id is required when trade_type is NATIVE');
194
+		if(!$product_id) {
195
+			throw new Exception('product_id is required when trade_type is NATIVE');
196
+		}
193 197
 		$data["product_id"]   = $product_id;
194 198
 		$result = $this->unifiedOrder($data);
195 199
 		return $result["code_url"];
@@ -213,7 +217,9 @@  discard block
 block discarded – undo
213 217
 		$data["spbill_create_ip"] = isset($_SERVER["REMOTE_ADDR"])?$_SERVER["REMOTE_ADDR"]:'';
214 218
 		$data["notify_url"]   = $this->config["notify_url"];
215 219
 		$data["trade_type"]   = self::TRADETYPE_MWEB;
216
-		if(!isset($this->config['h5_scene_info'])) throw new Exception('h5_scene_info should be configured');
220
+		if(!isset($this->config['h5_scene_info'])) {
221
+			throw new Exception('h5_scene_info should be configured');
222
+		}
217 223
 		$data["scene_info"]   = json_encode($this->config['h5_scene_info']);
218 224
 		$result = $this->unifiedOrder($data);
219 225
 		return $result["mweb_url"];
@@ -243,11 +249,15 @@  discard block
 block discarded – undo
243 249
 		$data["notify_url"] = $this->config["notify_url"];
244 250
 		$data["trade_type"] = $params['trade_type'];
245 251
 		if($params['trade_type'] == WechatPay::TRADETYPE_NATIVE){
246
-			if(!isset($params['product_id'])) throw new Exception('product_id is required when trade_type is NATIVE');
252
+			if(!isset($params['product_id'])) {
253
+				throw new Exception('product_id is required when trade_type is NATIVE');
254
+			}
247 255
 			$data["product_id"] = $params['product_id'];
248 256
 		}
249 257
 		if($params['trade_type'] == WechatPay::TRADETYPE_JSAPI){
250
-			if(!isset($params['openid'])) throw new Exception('openid is required when trade_type is JSAPI');
258
+			if(!isset($params['openid'])) {
259
+				throw new Exception('openid is required when trade_type is JSAPI');
260
+			}
251 261
 			$data["openid"] = $params['openid'];
252 262
 		}
253 263
 		$result = $this->post(self::URL_UNIFIEDORDER, $data);
@@ -490,7 +500,9 @@  discard block
 block discarded – undo
490 500
 		$data["send_name"] = $send_name;
491 501
 		$data["re_openid"] = $re_openid;
492 502
 		$data["total_amount"] = $total_amount;
493
-		if($total_amount > 20000 && trim($scene_id)=='') throw new Exception("scene_id is required when total_amount beyond 20000");
503
+		if($total_amount > 20000 && trim($scene_id)=='') {
504
+			throw new Exception("scene_id is required when total_amount beyond 20000");
505
+		}
494 506
 		$data["total_num"] = $total_num;
495 507
 		$data["wishing"] = $wishing;
496 508
 		$data["act_name"] = $act_name;
@@ -526,7 +538,9 @@  discard block
 block discarded – undo
526 538
 		$data["send_name"] = $send_name;
527 539
 		$data["re_openid"] = $re_openid;
528 540
 		$data["total_amount"] = $total_amount;
529
-		if($total_amount > 20000 && trim($scene_id)=='') throw new Exception("scene_id is required when total_amount beyond 20000(200rmb)");
541
+		if($total_amount > 20000 && trim($scene_id)=='') {
542
+			throw new Exception("scene_id is required when total_amount beyond 20000(200rmb)");
543
+		}
530 544
 		$data["total_num"] = $total_num;
531 545
 		$data["amt_type"] = 'ALL_RAND'; //红包金额设置方式 ALL_RAND—全部随机
532 546
 		$data["wishing"] = $wishing;
@@ -634,8 +648,12 @@  discard block
 block discarded – undo
634 648
 	 * @throws Exception
635 649
 	 */
636 650
 	public function onPaidNotify($notify_data,callable $callback = null){
637
-		if(!is_array($notify_data)) $notify_data = $this->xml2array($notify_data);
638
-		if(!$this->validateSign($notify_data)) throw new Exception('Invalid paid notify data');
651
+		if(!is_array($notify_data)) {
652
+			$notify_data = $this->xml2array($notify_data);
653
+		}
654
+		if(!$this->validateSign($notify_data)) {
655
+			throw new Exception('Invalid paid notify data');
656
+		}
639 657
 		if($callback && is_callable($callback)){
640 658
 			return call_user_func_array( $callback , [$notify_data] );
641 659
 		}
@@ -649,8 +667,12 @@  discard block
 block discarded – undo
649 667
 	 * @throws Exception
650 668
 	 */
651 669
 	public function onRefundedNotify($notify_data,callable $callback = null){
652
-		if(!is_array($notify_data)) $notify_data = $this->xml2array($notify_data);
653
-		if(!$this->validateSign($notify_data)) throw new Exception('Invalid refund notify data');
670
+		if(!is_array($notify_data)) {
671
+			$notify_data = $this->xml2array($notify_data);
672
+		}
673
+		if(!$this->validateSign($notify_data)) {
674
+			throw new Exception('Invalid refund notify data');
675
+		}
654 676
 		if($callback && is_callable($callback)){
655 677
 			return call_user_func_array( $callback ,[$notify_data] );
656 678
 		}
@@ -684,8 +706,11 @@  discard block
 block discarded – undo
684 706
 			$data["return_msg"] = $return_msg;
685 707
 		}
686 708
 		$xml = $this->array2xml($data);
687
-		if($print === true) print $xml;
688
-		else return $xml;
709
+		if($print === true) {
710
+			print $xml;
711
+		} else {
712
+			return $xml;
713
+		}
689 714
 	}
690 715
 
691 716
 	/**
@@ -713,12 +738,24 @@  discard block
 block discarded – undo
713 738
 		$data["return_code"] = $return_code;
714 739
 		$data["result_code"] = $result_code;
715 740
 		$data["user_ip"] = $user_ip;
716
-		if($out_trade_no) $data["out_trade_no"] = $out_trade_no;
717
-		if($time) $data["time"] = $time;
718
-		if($device_info) $data["device_info"] = $device_info;
719
-		if($return_msg) $data["return_msg"] = $return_msg;
720
-		if($err_code) $data["err_code"] = $err_code;
721
-		if($err_code_des) $data["err_code_des"] = $err_code_des;
741
+		if($out_trade_no) {
742
+			$data["out_trade_no"] = $out_trade_no;
743
+		}
744
+		if($time) {
745
+			$data["time"] = $time;
746
+		}
747
+		if($device_info) {
748
+			$data["device_info"] = $device_info;
749
+		}
750
+		if($return_msg) {
751
+			$data["return_msg"] = $return_msg;
752
+		}
753
+		if($err_code) {
754
+			$data["err_code"] = $err_code;
755
+		}
756
+		if($err_code_des) {
757
+			$data["err_code_des"] = $err_code_des;
758
+		}
722 759
 		$result = $this->post(self::URL_REPORT, $data, false);
723 760
 		return $result;
724 761
 	}
@@ -766,7 +803,9 @@  discard block
 block discarded – undo
766 803
 	 */
767 804
 	public function transferWallet($partner_trade_no,$openid,$amount,$desc,$spbill_create_ip = null,$re_user_name = null,$check_name = WechatPay::CHECKNAME_FORCECHECK){
768 805
 		$data = array();
769
-		if($check_name == WechatPay::CHECKNAME_FORCECHECK && !$re_user_name) throw new Exception('Real name is required');
806
+		if($check_name == WechatPay::CHECKNAME_FORCECHECK && !$re_user_name) {
807
+			throw new Exception('Real name is required');
808
+		}
770 809
 		$data["mch_appid"] = $this->config["app_id"];
771 810
 		$data["mchid"] = $this->config["mch_id"];
772 811
 		$data["partner_trade_no"] = $partner_trade_no;
@@ -808,7 +847,9 @@  discard block
 block discarded – undo
808 847
 	 * @throws Exception
809 848
 	 */
810 849
 	public function transferBankCard($partner_trade_no,$bank_no,$true_name,$bank_code,$amount,$desc){
811
-		if(!in_array($bank_code,array_values(self::$BANKCODE))) throw new Exception("Unsupported bank code: $bank_code");
850
+		if(!in_array($bank_code,array_values(self::$BANKCODE))) {
851
+			throw new Exception("Unsupported bank code: $bank_code");
852
+		}
812 853
 		$data = array();
813 854
 		$data["partner_trade_no"] = $partner_trade_no;
814 855
 		$enc_bank_no = $this->rsaEncrypt($bank_no);
@@ -904,7 +945,7 @@  discard block
 block discarded – undo
904 945
 		if(!$this->publicKey) {
905 946
 			if (!$refresh && file_exists($this->config["rsa_pubkey_path"])) {
906 947
 				$this->publicKey = file_get_contents($this->config["rsa_pubkey_path"]);
907
-			}else{
948
+			} else{
908 949
 				$data = array();
909 950
 				$data["mch_id"] = $this->config["mch_id"];
910 951
 				$data["sign_type"] = $this->config["sign_type"];
@@ -933,13 +974,16 @@  discard block
 block discarded – undo
933 974
 	}
934 975
 
935 976
 	public function rsaEncrypt($data,$pubkey = null){
936
-		if(!$pubkey) $pubkey = $this->getPublicKey();
977
+		if(!$pubkey) {
978
+			$pubkey = $this->getPublicKey();
979
+		}
937 980
 		$encrypted = null;
938 981
 		$pubkey = openssl_get_publickey($pubkey);
939
-		if (@openssl_public_encrypt($data, $encrypted, $pubkey,OPENSSL_PKCS1_OAEP_PADDING))
940
-			$data = base64_encode($encrypted);
941
-		else
942
-			throw new Exception('Unable to encrypt data');
982
+		if (@openssl_public_encrypt($data, $encrypted, $pubkey,OPENSSL_PKCS1_OAEP_PADDING)) {
983
+					$data = base64_encode($encrypted);
984
+		} else {
985
+					throw new Exception('Unable to encrypt data');
986
+		}
943 987
 		return $data;
944 988
 	}
945 989
 
@@ -962,7 +1006,9 @@  discard block
 block discarded – undo
962 1006
 	 * @return array
963 1007
 	 */
964 1008
 	public function getSignPackage($url, $ticket = null){
965
-		if(!$ticket) $ticket = $this->getTicket();
1009
+		if(!$ticket) {
1010
+			$ticket = $this->getTicket();
1011
+		}
966 1012
 		$timestamp = time();
967 1013
 		$nonceStr = $this->getNonceStr();
968 1014
 		$rawString = "jsapi_ticket=$ticket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
@@ -1004,9 +1050,15 @@  discard block
 block discarded – undo
1004 1050
 	}
1005 1051
 
1006 1052
 	private function post($url, $data,$cert = true) {
1007
-		if(!isset($data['mch_id']) && !isset($data['mchid'])) $data["mch_id"] = $this->config["mch_id"];
1008
-		if(!isset($data['nonce_str'])) $data["nonce_str"] = $this->getNonceStr();
1009
-		if(!isset($data['sign'])) $data['sign'] = $this->sign($data);
1053
+		if(!isset($data['mch_id']) && !isset($data['mchid'])) {
1054
+			$data["mch_id"] = $this->config["mch_id"];
1055
+		}
1056
+		if(!isset($data['nonce_str'])) {
1057
+			$data["nonce_str"] = $this->getNonceStr();
1058
+		}
1059
+		if(!isset($data['sign'])) {
1060
+			$data['sign'] = $this->sign($data);
1061
+		}
1010 1062
 		$this->requestXML = $this->responseXML = null;
1011 1063
 		$this->requestArray = $this->responseArray = null;
1012 1064
 
@@ -1034,12 +1086,16 @@  discard block
 block discarded – undo
1034 1086
 			$url = "{$host}/sandboxnew{$url}";
1035 1087
 		}
1036 1088
 		$content = $this->httpClient->post($url,$this->requestXML,[],$opts);
1037
-		if(!$content) throw new Exception("Empty response with {$this->requestXML}");
1089
+		if(!$content) {
1090
+			throw new Exception("Empty response with {$this->requestXML}");
1091
+		}
1038 1092
 
1039 1093
 		$this->responseXML = $content;
1040
-		if($processResponse)
1041
-			return $this->processResponseXML($this->responseXML);
1042
-		else return $this->responseXML;
1094
+		if($processResponse) {
1095
+					return $this->processResponseXML($this->responseXML);
1096
+		} else {
1097
+			return $this->responseXML;
1098
+		}
1043 1099
 
1044 1100
 	}
1045 1101
 
@@ -1063,7 +1119,7 @@  discard block
 block discarded – undo
1063 1119
 				$this->errCode = $result['err_code'];
1064 1120
 				$this->errCodeDes = $result['err_code_des'];
1065 1121
 				throw new Exception("[$this->errCode]$this->errCodeDes");
1066
-			}else{
1122
+			} else{
1067 1123
 				return $result;
1068 1124
 			}
1069 1125
 		} else if($this->returnCode == 'FAIL'){
@@ -1082,17 +1138,20 @@  discard block
 block discarded – undo
1082 1138
 		$stringSignTemp = $string1 . "key=" . $this->config["api_key"];
1083 1139
 		if($sign_type == WechatPay::SIGNTYPE_MD5){
1084 1140
 			$sign = strtoupper(md5($stringSignTemp));
1085
-		}elseif($sign_type == WechatPay::SIGNTYPE_HMACSHA256){
1141
+		} elseif($sign_type == WechatPay::SIGNTYPE_HMACSHA256){
1086 1142
 			$sign = strtoupper(hash_hmac('sha256',$stringSignTemp,$this->config["api_key"]));
1087
-		}else throw new Exception("Not supported sign type - $sign_type");
1143
+		} else {
1144
+			throw new Exception("Not supported sign type - $sign_type");
1145
+		}
1088 1146
 		return $sign;
1089 1147
 	}
1090 1148
 
1091 1149
 	private function array2xml($array) {
1092 1150
 		$xml = "<xml>" . PHP_EOL;
1093 1151
 		foreach ($array as $k => $v) {
1094
-			if($v && trim($v)!='')
1095
-				$xml .= "<$k><![CDATA[$v]]></$k>" . PHP_EOL;
1152
+			if($v && trim($v)!='') {
1153
+							$xml .= "<$k><![CDATA[$v]]></$k>" . PHP_EOL;
1154
+			}
1096 1155
 		}
1097 1156
 		$xml .= "</xml>";
1098 1157
 		return $xml;
@@ -1103,7 +1162,7 @@  discard block
 block discarded – undo
1103 1162
 		$tmp = null;
1104 1163
 		try{
1105 1164
 			$tmp = (array) simplexml_load_string($xml);
1106
-		}catch(Exception $e){
1165
+		} catch(Exception $e){
1107 1166
 			throw $e;
1108 1167
 		}
1109 1168
 		foreach ( $tmp as $k => $v) {
Please login to merge, or discard this patch.
demo/wxoauthcallback.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 
14 14
 	if(!$at || empty($at->openid)){
15 15
 		die('授权失败');
16
-	}else{
16
+	} else{
17 17
 		$accesstoken = $at->access_token;
18 18
 		$openid = $at->openid;
19 19
 		header('Location: '."http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/pay.php?openid=$openid");
20 20
 	}
21
-}else{
21
+} else{
22 22
 	die('授权失败,请重试。');
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 //OAuth授权回调
4
-require_once __DIR__ . "/autoload.php";
4
+require_once __DIR__."/autoload.php";
5 5
 use zhangv\wechat\WechatOAuth;
6 6
 
7
-if (isset($_GET['code'])){
7
+if (isset($_GET['code'])) {
8 8
 	$cfg = require './config.php';
9 9
 
10 10
 	$code = trim($_GET['code']);
11 11
 	$state = trim($_GET['state']);
12
-	$oauth = new WechatOAuth($cfg['app_id'],$cfg['app_secret']);
12
+	$oauth = new WechatOAuth($cfg['app_id'], $cfg['app_secret']);
13 13
 	$at = $oauth->authorize($code);
14 14
 
15
-	if(!$at || empty($at->openid)){
15
+	if (!$at || empty($at->openid)) {
16 16
 		die('授权失败');
17
-	}else{
17
+	}else {
18 18
 		$accesstoken = $at->access_token;
19 19
 		$openid = $at->openid;
20 20
 		header('Location: '."http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/pay.php?openid=$openid");
21 21
 	}
22
-}else{
22
+}else {
23 23
 	die('授权失败,请重试。');
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
demo/config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@
 block discarded – undo
5 5
 	'app_id'            => 'XXXXXXXXXXXXXXXXXXX', //APPID
6 6
 	'app_secret'        => 'XXXXXXXXXXXXXXXXXXXXXXXXX', //App Secret
7 7
 	'api_key'           =>'XXXXXXXXXXXXXXXXXXXXXXX', //支付密钥
8
-	'ssl_cert_path'     => __DIR__ . '/../cert/apiclient_cert.pem',
9
-	'ssl_key_path'      => __DIR__ .'/../cert/apiclient_key.pem',
8
+	'ssl_cert_path'     => __DIR__.'/../cert/apiclient_cert.pem',
9
+	'ssl_key_path'      => __DIR__.'/../cert/apiclient_key.pem',
10 10
 	'sign_type'         => 'MD5',
11 11
 	'notify_url'        => 'http://XXX.XXX/paidnotify.php',
12 12
 	'refund_notify_url' => 'http://XXX.XXX/refundednotify.php',
13 13
 	'h5_scene_info'     => [//required in H5
14 14
 		'h5_info' => ['type' => 'Wap', 'wap_url' => 'http://wapurl', 'wap_name' => 'wapname']
15 15
 	],
16
-	'rsa_pubkey_path'   => __DIR__ .'/../cert/pubkey.pem',
17
-	'jsapi_ticket'      => __DIR__ .'/jsapi_ticket.json'
16
+	'rsa_pubkey_path'   => __DIR__.'/../cert/pubkey.pem',
17
+	'jsapi_ticket'      => __DIR__.'/jsapi_ticket.json'
18 18
 ];
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
demo/pay-qrcode.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 //扫码支付
4
-require_once __DIR__ . "/autoload.php";
4
+require_once __DIR__."/autoload.php";
5 5
 use zhangv\wechat\WechatPay;
6 6
 
7 7
 $cfg = include './config.php';
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $desc = "desc$stamp";
13 13
 $productid = "testproduct";
14 14
 $amt = 1;
15
-$codeurl = $payment->getCodeUrl($desc, $orderid, $amt,$productid);
15
+$codeurl = $payment->getCodeUrl($desc, $orderid, $amt, $productid);
16 16
 
17 17
 ?>
18 18
 <script type="text/javascript" src="js/jquery.js"></script>
Please login to merge, or discard this patch.
demo/autoload.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(file_exists(__DIR__ . '/../vendor/autoload.php')){
3
+if (file_exists(__DIR__.'/../vendor/autoload.php')) {
4 4
 	/** @var \Composer\Autoload\ClassLoader $loader */
5
-	$loader = require __DIR__ . '/../vendor/autoload.php';
6
-}else{//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing
5
+	$loader = require __DIR__.'/../vendor/autoload.php';
6
+}else {//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing
7 7
 	function __autoload($class) {
8 8
 		$class = str_replace('zhangv\\wechat\\', 'src/', $class);
9
-		$file = __DIR__ . '/../' . $class . '.php';
9
+		$file = __DIR__.'/../'.$class.'.php';
10 10
 		require_once $file;
11 11
 	}
12 12
 	spl_autoload_register('__autoload');
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 if(file_exists(__DIR__ . '/../vendor/autoload.php')){
4 4
 	/** @var \Composer\Autoload\ClassLoader $loader */
5 5
 	$loader = require __DIR__ . '/../vendor/autoload.php';
6
-}else{//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing
6
+} else{//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing
7 7
 	function __autoload($class) {
8 8
 		$class = str_replace('zhangv\\wechat\\', 'src/', $class);
9 9
 		$file = __DIR__ . '/../' . $class . '.php';
Please login to merge, or discard this patch.
demo/wxoauth.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 //OAuth授权
4
-require_once __DIR__ . "/autoload.php";
4
+require_once __DIR__."/autoload.php";
5 5
 
6 6
 use zhangv\wechat\WechatOAuth;
7 7
 
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $redirect = "http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/wxoauthcallback.php";
11 11
 $scope = 'snsapi_userinfo';
12 12
 $state = "";
13
-$oauth =new WechatOAuth($appid,$cfg['app_secret']);
14
-$url = $oauth->authorizeURI($redirect,$scope);
13
+$oauth = new WechatOAuth($appid, $cfg['app_secret']);
14
+$url = $oauth->authorizeURI($redirect, $scope);
15 15
 
16 16
 header('Location: '.$redirect);
17 17
\ No newline at end of file
Please login to merge, or discard this patch.
demo/refundednotify.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . "/autoload.php";
3
+require_once __DIR__."/autoload.php";
4 4
 use zhangv\wechat\WechatPay;
5 5
 
6 6
 $xml = file_get_contents("php://input");
7 7
 
8 8
 $cfg = require './config.php';
9 9
 $payment = new WechatPay($cfg);
10
-$payment->onRefundedNotify($xml,function($notifydata) use ($payment){
10
+$payment->onRefundedNotify($xml, function($notifydata) use ($payment){
11 11
 	//do stuff
12 12
 	print_r($notifydata);
13 13
 	$payment->responseNotify();
Please login to merge, or discard this patch.
demo/pay.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 //公众号支付
4
-require_once __DIR__ . "/autoload.php";
4
+require_once __DIR__."/autoload.php";
5 5
 
6 6
 use zhangv\wechat\WechatPay;
7 7
 $cfg = include './config.php';
8 8
 
9
-if(empty( $_REQUEST['openid'])) {
9
+if (empty($_REQUEST['openid'])) {
10 10
 	$redirect = "http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/wxoauth.php";
11 11
 	header('Location: '.$redirect);
12 12
 	exit;
Please login to merge, or discard this patch.
demo/pay-app.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 //APP支付 - 获取预支付交易回话标识
4 4
 //注意:APP支付使用的是开放平台的APPID
5
-require_once __DIR__ . "/autoload.php";
5
+require_once __DIR__."/autoload.php";
6 6
 
7 7
 use zhangv\wechat\WechatPay;
8 8
 
Please login to merge, or discard this patch.