Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

101 строка
3.1 KiB

  1. <?php
  2. ini_set('date.timezone','Asia/Shanghai');
  3. //error_reporting(E_ERROR);
  4. require_once "../lib/WxPay.Api.php";
  5. require_once "WxPay.NativePay.php";
  6. require_once 'log.php';
  7. require_once '../../Common/Function.php';
  8. //模式一
  9. /**
  10. * 流程:
  11. * 1、组装包含支付信息的url,生成二维码
  12. * 2、用户扫描二维码,进行支付
  13. * 3、确定支付之后,微信服务器会回调预先配置的回调地址,在【微信开放平台-微信支付-支付配置】中进行配置
  14. * 4、在接到回调通知之后,用户进行统一下单支付,并返回支付信息以完成支付(见:native_notify.php)
  15. * 5、支付完成之后,微信服务器会通知支付成功
  16. * 6、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
  17. */
  18. //初始化日志
  19. $logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
  20. $log = Log::Init($logHandler, 15);
  21. //打印输出数组信息
  22. function printf_info($data)
  23. {
  24. foreach($data as $key=>$value){
  25. echo "<font color='#00ff55;'>$key</font> : $value <br/>";
  26. }
  27. }
  28. if (!empty($_GET['orderid']) && $_GET['orderid'] !=='false'){
  29. $orderno=$_GET['orderid'];
  30. }else{
  31. echo "<script>alert('订单号有误')</script>";
  32. exit;
  33. }
  34. $notify = new NativePay();
  35. //模式二
  36. /**
  37. * 流程:
  38. * 1、调用统一下单,取得code_url,生成二维码
  39. * 2、用户扫描二维码,进行支付
  40. * 3、支付完成之后,微信服务器会通知支付成功
  41. * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
  42. */
  43. $url="http://xmwxc.zhizhuchuxing.cn/fx/order_detail.php?orderno=".$orderno;
  44. $result=http_request($url);
  45. $orderDetail=json_decode($result,true);
  46. // die;
  47. if($orderDetail['order_status']==146){
  48. $successurl="http://xmwxc.zhizhuchuxing.cn/fx/order_detail.php?orderno=".$orderno;
  49. Header("Location: $successurl");
  50. exit;
  51. }
  52. $money=1;//(int)$orderDetail['order_price'];
  53. //var_dump($money);die;
  54. if ($money == 0){
  55. $successurl="http://xmwxc.zhizhuchuxing.cn/fx/order_detail.php?orderno=".$orderno;
  56. Header("Location: $successurl");
  57. exit;
  58. }
  59. $name=$orderDetail['prod_name'];
  60. $reurl=dirname("http://xmwxc.zhizhuchuxing.cn/wechat/WxPay/realpay/success_notify_fx.php");
  61. //var_dump($result);die;
  62. $SetBody=$name.": ".$orderno;
  63. $input = new WxPayUnifiedOrder();
  64. $input->SetBody($SetBody);
  65. $input->SetAttach("xi");
  66. $SetOut_trade_no=$orderno."-".date("ymdHis");
  67. $input->SetOut_trade_no($SetOut_trade_no);
  68. $input->SetTotal_fee($money);
  69. $input->SetTime_start(date("YmdHis"));
  70. $input->SetTime_expire(date("YmdHis", time() + 600));
  71. $input->SetGoods_tag("代金券");
  72. $input->SetNotify_url($reurl);
  73. $SetTrade_type="NATIVE";
  74. $input->SetTrade_type("$SetTrade_type");
  75. $input->SetProduct_id($orderno);
  76. $result = $notify->GetPayUrl($input);
  77. $url2 = $result["code_url"];
  78. //ile_put_contents('native.log', $url2);
  79. ?>
  80. <img alt="模式二扫码支付" src="http://xmwxc.zhizhuchuxing.cn/wechat/WxPay/phprcode_fx/qrcode.php?data=<?php echo urlencode($url2);?>" style="width:150px;height:150px;"/>