|
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/native.php?chapter=9_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 Native extends WechatPay { |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* 扫码支付(模式二)获取支付二维码 |
|
32
|
|
|
* @param $body |
|
33
|
|
|
* @param $out_trade_no |
|
34
|
|
|
* @param $total_fee |
|
35
|
|
|
* @param $product_id |
|
36
|
|
|
* @param $spbill_create_ip string 本地IP |
|
37
|
|
|
* @param $ext array |
|
38
|
|
|
* @return string |
|
39
|
|
|
* @throws Exception |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function getCodeUrl($body,$out_trade_no,$total_fee,$product_id,$spbill_create_ip = null,$ext = null){ |
|
42
|
1 |
|
$data = ($ext && is_array($ext))?$ext:array(); |
|
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?:$_SERVER["SERVER_ADDR"]; |
|
47
|
1 |
|
$data["notify_url"] = $this->config["notify_url"]; |
|
48
|
1 |
|
$data["trade_type"] = self::TRADETYPE_NATIVE; |
|
49
|
1 |
|
if(!$product_id) throw new Exception('product_id is required when trade_type is NATIVE'); |
|
50
|
1 |
|
$data["product_id"] = $product_id; |
|
51
|
1 |
|
$result = $this->unifiedOrder($data); |
|
52
|
1 |
|
return $result["code_url"]; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
} |