|
- <?php
- ini_set('date.timezone','Asia/Shanghai');
- //error_reporting(E_ERROR);
-
- require_once "../lib/WxPay.Api.php";
- require_once "WxPay.NativePay.php";
- require_once 'log.php';
- require_once '../../Common/Function.php';
-
- //模式一
- /**
- * 流程:
- * 1、组装包含支付信息的url,生成二维码
- * 2、用户扫描二维码,进行支付
- * 3、确定支付之后,微信服务器会回调预先配置的回调地址,在【微信开放平台-微信支付-支付配置】中进行配置
- * 4、在接到回调通知之后,用户进行统一下单支付,并返回支付信息以完成支付(见:native_notify.php)
- * 5、支付完成之后,微信服务器会通知支付成功
- * 6、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
- */
-
-
- //初始化日志
- $logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
- $log = Log::Init($logHandler, 15);
-
- //打印输出数组信息
- function printf_info($data)
- {
- foreach($data as $key=>$value){
- echo "<font color='#00ff55;'>$key</font> : $value <br/>";
- }
- }
- if (!empty($_GET['orderid']) && $_GET['orderid'] !=='false'){
- $orderno=$_GET['orderid'];
- }else{
- echo "<script>alert('订单号有误')</script>";
- exit;
- }
- $notify = new NativePay();
-
- //模式二
- /**
- * 流程:
- * 1、调用统一下单,取得code_url,生成二维码
- * 2、用户扫描二维码,进行支付
- * 3、支付完成之后,微信服务器会通知支付成功
- * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
- */
-
- $url="http://xmwxc.zhizhuchuxing.cn/fx/order_detail.php?orderno=".$orderno;
- $result=http_request($url);
- $orderDetail=json_decode($result,true);
- // die;
- if($orderDetail['order_status']==146){
- $successurl="http://xmwxc.zhizhuchuxing.cn/fx/order_detail.php?orderno=".$orderno;
- Header("Location: $successurl");
- exit;
- }
- $money=1;//(int)$orderDetail['order_price'];
- //var_dump($money);die;
- if ($money == 0){
- $successurl="http://xmwxc.zhizhuchuxing.cn/fx/order_detail.php?orderno=".$orderno;
- Header("Location: $successurl");
- exit;
- }
- $name=$orderDetail['prod_name'];
- $reurl=dirname("http://xmwxc.zhizhuchuxing.cn/wechat/WxPay/realpay/success_notify_fx.php");
- //var_dump($result);die;
- $SetBody=$name.": ".$orderno;
-
- $input = new WxPayUnifiedOrder();
- $input->SetBody($SetBody);
- $input->SetAttach("xi");
- $SetOut_trade_no=$orderno."-".date("ymdHis");
- $input->SetOut_trade_no($SetOut_trade_no);
- $input->SetTotal_fee($money);
- $input->SetTime_start(date("YmdHis"));
- $input->SetTime_expire(date("YmdHis", time() + 600));
- $input->SetGoods_tag("代金券");
- $input->SetNotify_url($reurl);
-
- $SetTrade_type="NATIVE";
- $input->SetTrade_type("$SetTrade_type");
- $input->SetProduct_id($orderno);
- $result = $notify->GetPayUrl($input);
- $url2 = $result["code_url"];
-
- //ile_put_contents('native.log', $url2);
- ?>
-
-
-
- <img alt="模式二扫码支付" src="http://xmwxc.zhizhuchuxing.cn/wechat/WxPay/phprcode_fx/qrcode.php?data=<?php echo urlencode($url2);?>" style="width:150px;height:150px;"/>
-
-
-
-
-
-
|