|
1
|
|
|
<?php |
|
2
|
|
|
namespace zhangv\wechat\pay\service; |
|
3
|
|
|
use \zhangv\wechat\pay\WechatPay; |
|
4
|
|
|
use \Exception; |
|
5
|
|
|
/** |
|
6
|
|
|
* 刷卡支付 |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
* @zhangv |
|
9
|
|
|
* @link https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1 |
|
10
|
|
|
* |
|
11
|
|
|
* @method mixed queryOrderByOutTradeNo($out_trade_no) |
|
12
|
|
|
* @method mixed queryOrderByTransactionId($transaction_id) |
|
13
|
|
|
* @method mixed closeOrder($out_trade_no) |
|
14
|
|
|
* @method mixed refundByOutTradeNo($out_trade_no, $out_refund_no, $total_fee, $refund_fee, $ext = array()) |
|
15
|
|
|
* @method mixed refundByTransactionId($transaction_id, $out_refund_no, $total_fee, $refund_fee, $ext = array()) |
|
16
|
|
|
* @method mixed queryRefundByOutRefundNo($out_refund_no, $offset = 0) |
|
17
|
|
|
* @method mixed queryRefundByOutTradeNo($out_trade_no, $offset = 0) |
|
18
|
|
|
* @method mixed queryRefundByRefundId($refund_id, $offset = 0) |
|
19
|
|
|
* @method mixed queryRefundByTransactionId($transaction_id, $offset = 0) |
|
20
|
|
|
* @method mixed downloadBill($bill_date, $bill_type = 'ALL') |
|
21
|
|
|
* @method mixed downloadFundFlow($bill_date, $account_type = WechatPay::ACCOUNTTYPE_BASIC, $tar_type = 'GZIP') |
|
22
|
|
|
* @method mixed onPaidNotify($notify_data, callable $callback = null) |
|
23
|
|
|
* @method mixed onRefundedNotify($notify_data, callable $callback = null) |
|
24
|
|
|
* @method mixed report($interface_url, $execution_time, $return_code, $result_code, $user_ip, $out_trade_no = null, $time = null, $device_info = null,$return_msg = null,$err_code = null,$err_code_des = null) |
|
25
|
|
|
* @method mixed shortUrl($longurl) |
|
26
|
|
|
* @method mixed batchQueryComment($begin_time, $end_time, $offset = 0, $limit = 200) |
|
27
|
|
|
*/ |
|
28
|
|
|
class Micro extends WechatPay { |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* 提交刷卡支付 |
|
32
|
|
|
* @param $body |
|
33
|
|
|
* @param $out_trade_no |
|
34
|
|
|
* @param $total_fee |
|
35
|
|
|
* @param $spbill_create_ip |
|
36
|
|
|
* @param $auth_code |
|
37
|
|
|
* @param array $ext |
|
38
|
|
|
* @return array |
|
39
|
|
|
* @throws Exception |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function microPay($body,$out_trade_no,$total_fee,$spbill_create_ip,$auth_code,$ext = array()){ |
|
42
|
1 |
|
$data = (!empty($ext) && is_array($ext))?$ext:array(); |
|
43
|
1 |
|
$data["appid"] = $this->config["app_id"]; |
|
44
|
1 |
|
$data["body"] = $body; |
|
45
|
1 |
|
$data["out_trade_no"] = $out_trade_no; |
|
46
|
1 |
|
$data["total_fee"] = $total_fee; |
|
47
|
1 |
|
$data["spbill_create_ip"] = $spbill_create_ip; |
|
48
|
1 |
|
$data["auth_code"] = $auth_code; |
|
49
|
1 |
|
return $this->post(self::URL_MICROPAY,$data,true); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* 授权码查询openid |
|
54
|
|
|
* @param $auth_code |
|
55
|
|
|
* @return mixed |
|
56
|
|
|
* @throws Exception |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public function authCodeToOpenId($auth_code){ |
|
59
|
1 |
|
$data = array(); |
|
60
|
1 |
|
$data["appid"] = $this->config["app_id"]; |
|
61
|
1 |
|
$data["auth_code"] = $auth_code; |
|
62
|
1 |
|
return $this->post(self::URL_AUTHCODETOOPENID,$data,false); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* 撤销订单 - 使用商户订单号 |
|
68
|
|
|
* @param $out_trade_no string 商户订单号 |
|
69
|
|
|
* @return array |
|
70
|
|
|
* @throws Exception |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function reverseByOutTradeNo($out_trade_no){ |
|
73
|
1 |
|
$data = array(); |
|
74
|
1 |
|
$data["appid"] = $this->config["app_id"]; |
|
75
|
1 |
|
$data["out_trade_no"] = $out_trade_no; |
|
76
|
1 |
|
return $this->post(self::URL_REVERSE, $data,true); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* 撤销订单 - 使用微信订单号 |
|
81
|
|
|
* @param $transaction_id string 微信订单号 |
|
82
|
|
|
* @return array |
|
83
|
|
|
* @throws Exception |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function reverseByTransactionId($transaction_id){ |
|
86
|
1 |
|
$data = array(); |
|
87
|
1 |
|
$data["appid"] = $this->config["app_id"]; |
|
88
|
1 |
|
$data["transaction_id"] = $transaction_id; |
|
89
|
1 |
|
return $this->post(self::URL_REVERSE, $data,true); |
|
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
} |