payend.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. require("../../class/connect.php");
  3. require("../../class/db_sql.php");
  4. require("../../class/q_functions.php");
  5. require("../../member/class/user.php");
  6. eCheckCloseMods('pay');//关闭模块
  7. $link=db_connect();
  8. $empire=new mysqlquery();
  9. $editor=1;
  10. //订单号
  11. if(!getcvar('checkpaysession'))
  12. {
  13. printerror('非法操作','../../../',1,0,1);
  14. }
  15. else
  16. {
  17. esetcookie("checkpaysession","",0);
  18. }
  19. //操作事件
  20. $phome=getcvar('payphome');
  21. if($phome=='PayToFen')//购买点数
  22. {}
  23. elseif($phome=='PayToMoney')//存预付款
  24. {}
  25. elseif($phome=='ShopPay')//商城支付
  26. {}
  27. elseif($phome=='BuyGroupPay')//购买充值类型
  28. {}
  29. else
  30. {
  31. printerror('您来自的链接不存在','',1,0,1);
  32. }
  33. $user=array();
  34. if($phome=='PayToFen'||$phome=='PayToMoney'||$phome=='BuyGroupPay')
  35. {
  36. $user=islogin();//是否登陆
  37. }
  38. $paytype='tenpay';
  39. $payr=$empire->fetch1("select * from {$dbtbpre}enewspayapi where paytype='$paytype' limit 1");
  40. if(!$payr['payid']||$payr['isclose'])
  41. {
  42. printerror('您来自的链接不存在','',1,0,1);
  43. }
  44. $bargainor_id=$payr['payuser'];//商户号
  45. $key=$payr['paykey'];//密钥
  46. //----------------------------------------------返回信息
  47. /*
  48. import_request_variables("gpc", "frm_");
  49. $strCmdno = $frm_cmdno;
  50. $strPayResult = $frm_pay_result;
  51. $strPayInfo = $frm_pay_info;
  52. $strBillDate = $frm_date;
  53. $strBargainorId = $frm_bargainor_id;
  54. $strTransactionId = $frm_transaction_id;
  55. $strSpBillno = $frm_sp_billno;
  56. $strTotalFee = $frm_total_fee;
  57. $strFeeType = $frm_fee_type;
  58. $strAttach = $frm_attach;
  59. $strMd5Sign = $frm_sign;
  60. */
  61. if(!empty($_POST))
  62. {
  63. foreach($_POST as $key => $data)
  64. {
  65. $_GET[$key]=$data;
  66. }
  67. }
  68. $strCmdno = $_GET['cmdno'];
  69. $strPayResult = $_GET['pay_result'];
  70. $strPayInfo = $_GET['pay_info'];
  71. $strBillDate = $_GET['date'];
  72. $strBargainorId = $_GET['bargainor_id'];
  73. $strTransactionId = $_GET['transaction_id'];
  74. $strSpBillno = $_GET['sp_billno'];
  75. $strTotalFee = $_GET['total_fee'];
  76. $strFeeType = $_GET['fee_type'];
  77. $strAttach = $_GET['attach'];
  78. $strMd5Sign = $_GET['sign'];
  79. //支付验证
  80. $checkkey="cmdno=".$strCmdno."&pay_result=".$strPayResult."&date=".$strBillDate."&transaction_id=".$strTransactionId."&sp_billno=".$strSpBillno."&total_fee=".$strTotalFee."&fee_type=".$strFeeType."&attach=".$strAttach."&key=".$key;
  81. $checkSign=strtoupper(md5($checkkey));
  82. if('dg'.$checkSign!='dg'.$strMd5Sign)
  83. {
  84. printerror('验证MD5签名失败.','../../../',1,0,1);
  85. }
  86. if($bargainor_id!=$strBargainorId)
  87. {
  88. printerror('错误的商户号.','../../../',1,0,1);
  89. }
  90. if($strPayResult!="0")
  91. {
  92. printerror('支付失败.','../../../',1,0,1);
  93. }
  94. //----------- 支付成功后处理 -----------
  95. include('../payfun.php');
  96. $pr=$empire->fetch1("select paymoneytofen,payminmoney from {$dbtbpre}enewspublic limit 1");
  97. $orderid=$strSpBillno; //支付订单
  98. $ddno=$strAttach; //网站的订单号
  99. $money=$strTotalFee/100;
  100. $fen=floor($money)*$pr[paymoneytofen];
  101. if($phome=='PayToFen')//购买点数
  102. {
  103. $paybz='购买点数: '.$fen;
  104. PayApiBuyFen($fen,$money,$paybz,$orderid,$user[userid],$user[username],$paytype);
  105. }
  106. elseif($phome=='PayToMoney')//存预付款
  107. {
  108. $paybz='存预付款';
  109. PayApiPayMoney($money,$paybz,$orderid,$user[userid],$user[username],$paytype);
  110. }
  111. elseif($phome=='ShopPay')//商城支付
  112. {
  113. include('../../data/dbcache/class.php');
  114. $ddid=(int)getcvar('paymoneyddid');
  115. $paybz='商城购买 [!--ddno--] 的订单(ddid='.$ddid.')';
  116. PayApiShopPay($ddid,$money,$paybz,$orderid,'','',$paytype);
  117. }
  118. elseif($phome=='BuyGroupPay')//购买充值类型
  119. {
  120. include("../../data/dbcache/MemberLevel.php");
  121. $bgid=(int)getcvar('paymoneybgid');
  122. PayApiBuyGroupPay($bgid,$money,$orderid,$user[userid],$user[username],$user[groupid],$paytype);
  123. }
  124. db_close();
  125. $empire=null;
  126. ?>