Commit e0374dc 1 parent 6f88207 commit e0374dc Copy full SHA for e0374dc
File tree 1 file changed +50
-1
lines changed
1 file changed +50
-1
lines changed Original file line number Diff line number Diff line change 1
1
# thinkphp5.1-weixinpay
2
- thinkphp5.1 微信支付
2
+
3
+ thinkphp5.1 微信网站扫码支付
4
+
5
+ 将目录下的weixinpay.php移到config目录,修改对应参数即可。
6
+
7
+ 公共函数:
8
+ <pre >
9
+ /**
10
+ * 微信扫码支付
11
+ * @param array $order 订单 必须包含支付所需要的参数 body(产品描述)、total_fee(订单金额)、out_trade_no(订单号)、product_id(产品id)
12
+ */
13
+ function weixinpay($order){
14
+ $order['trade_type']='NATIVE';
15
+ $weixinpay = new mangdin\weixinpay\Weixinpay();
16
+ return $weixinpay->pay($order);
17
+
18
+ }
19
+ </pre >
20
+
21
+ 控制器调用支付代码
22
+ <pre >
23
+ /**
24
+ * 微信PC 扫码支付
25
+ * @param $orderid 订单ID
26
+ */
27
+ public function weixinpay($orderid){
28
+ $order=array(
29
+ 'body'=>$subject['goods']['title'], //订单描述
30
+ 'total_fee'=>$price*100, //订单金额
31
+ 'out_trade_no'=>$subject['sn'], //订单编号
32
+ 'product_id'=>$subject['goods']['id'] //商品ID,可不传
33
+ );
34
+ $url = weixinpay($order); //该URL地址即为扫码支付地址,将此地址转为二维码即可
35
+ }
36
+ </pre >
37
+
38
+ 回调控制器代码
39
+ <pre >
40
+ /**
41
+ * notify_url接收页面
42
+ */
43
+ public function notify(){
44
+ // 导入微信支付sdk
45
+ $wxpay=new \mangdin\weixinpay\Weixinpay();
46
+ $result=$wxpay->notify();
47
+ if ($result) {
48
+ // 验证成功 修改数据库的订单状态等 $result['out_trade_no']为订单号
49
+ }
50
+ }
51
+ </pre >
You can’t perform that action at this time.
0 commit comments