Completed
Push — master ( 76d6fa...9bc9b6 )
by Wei
08:43
created

Micro   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 65
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A microPay() 0 10 3
A reverseByTransactionId() 0 6 1
A reverseByOutTradeNo() 0 6 1
A authCodeToOpenId() 0 6 1
1
<?php
2
namespace zhangv\wechat\pay\service;
3
use \zhangv\wechat\pay\WechatPay;
4
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
	 */
40 1
	public function microPay($body,$out_trade_no,$total_fee,$spbill_create_ip,$auth_code,$ext = array()){
41 1
		$data = (!empty($ext) && is_array($ext))?$ext:array();
42 1
		$data["appid"] = $this->config["app_id"];
43 1
		$data["body"]         = $body;
44 1
		$data["out_trade_no"] = $out_trade_no;
45 1
		$data["total_fee"]    = $total_fee;
46 1
		$data["spbill_create_ip"] = $spbill_create_ip;
47 1
		$data["auth_code"] = $auth_code;
48 1
		$result = $this->post(self::URL_MICROPAY,$data,true);
49 1
		return $result;
50
	}
51
52
	/**
53
	 * 授权码查询openid
54
	 *
55
	 * @param $auth_code
56
	 * @return mixed
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
		$result = $this->post(self::URL_AUTHCODETOOPENID,$data,false);
63 1
		return $result['openid'];
64
	}
65
66
67
	/**
68
	 * 撤销订单 - 使用商户订单号
69
	 * @link  https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3
70
	 * @param $out_trade_no string 商户订单号
71
	 * @return array
72
	 */
73 1
	public function reverseByOutTradeNo($out_trade_no){
74 1
		$data = array();
75 1
		$data["appid"] = $this->config["app_id"];
76 1
		$data["out_trade_no"] = $out_trade_no;
77 1
		$result = $this->post(self::URL_REVERSE, $data,true);
78 1
		return $result;
79
	}
80
81
	/**
82
	 * 撤销订单 - 使用微信订单号
83
	 * @link  https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3
84
	 * @param $transaction_id string 微信订单号
85
	 * @return array
86
	 */
87 1
	public function reverseByTransactionId($transaction_id){
88 1
		$data = array();
89 1
		$data["appid"] = $this->config["app_id"];
90 1
		$data["transaction_id"] = $transaction_id;
91 1
		$result = $this->post(self::URL_REVERSE, $data,true);
92 1
		return $result;
93
	}
94
}