payend.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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='alipay';
  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. $paykey=$payr['paykey'];//密钥
  46. $seller_email=$payr['payemail'];//卖家支付宝帐户
  47. //----------------------------------------------返回信息
  48. if(!empty($_POST))
  49. {
  50. foreach($_POST as $key => $data)
  51. {
  52. $_GET[$key]=$data;
  53. }
  54. }
  55. $get_seller_email=rawurldecode($_GET['seller_email']);
  56. //支付验证
  57. ksort($_GET);
  58. reset($_GET);
  59. $sign='';
  60. foreach($_GET AS $key=>$val)
  61. {
  62. if($key!='sign'&&$key!='sign_type'&&$key!='code')
  63. {
  64. $sign.="$key=$val&";
  65. }
  66. }
  67. $sign=md5(substr($sign,0,-1).$paykey);
  68. if('dg'.$sign!='dg'.$_GET['sign'])
  69. {
  70. printerror('验证MD5签名失败.','../../../',1,0,1);
  71. }
  72. if(!($_GET['trade_status']=="TRADE_FINISHED"||$_GET['trade_status']=="WAIT_SELLER_SEND_GOODS"||$_GET['trade_status']=="TRADE_SUCCESS"))
  73. {
  74. printerror('支付失败.','../../../',1,0,1);
  75. }
  76. //----------- 支付成功后处理 -----------
  77. include('../payfun.php');
  78. $pr=$empire->fetch1("select paymoneytofen,payminmoney from {$dbtbpre}enewspublic limit 1");
  79. $orderid=$_GET['trade_no']; //支付订单
  80. $ddno=$_GET['out_trade_no']; //网站的订单号
  81. $money=$_GET['total_fee'];
  82. $fen=floor($money)*$pr[paymoneytofen];
  83. if($phome=='PayToFen')//购买点数
  84. {
  85. $paybz='购买点数: '.$fen;
  86. PayApiBuyFen($fen,$money,$paybz,$orderid,$user[userid],$user[username],$paytype);
  87. }
  88. elseif($phome=='PayToMoney')//存预付款
  89. {
  90. $paybz='存预付款';
  91. PayApiPayMoney($money,$paybz,$orderid,$user[userid],$user[username],$paytype);
  92. }
  93. elseif($phome=='ShopPay')//商城支付
  94. {
  95. include('../../data/dbcache/class.php');
  96. $ddid=(int)getcvar('paymoneyddid');
  97. $paybz='商城购买 [!--ddno--] 的订单(ddid='.$ddid.')';
  98. PayApiShopPay($ddid,$money,$paybz,$orderid,'','',$paytype);
  99. }
  100. elseif($phome=='BuyGroupPay')//购买充值类型
  101. {
  102. include("../../data/dbcache/MemberLevel.php");
  103. $bgid=(int)getcvar('paymoneybgid');
  104. PayApiBuyGroupPay($bgid,$money,$orderid,$user[userid],$user[username],$user[groupid],$paytype);
  105. }
  106. db_close();
  107. $empire=null;
  108. ?>