payend.php
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/q_functions.php");
require("../../member/class/user.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//訂單號
if(!getcvar('checkpaysession'))
{
printerror('非法操作','../../../',1,0,1);
}
else
{
esetcookie("checkpaysession","",0);
}
//操作事件
$phome=getcvar('payphome');
if($phome=='PayToFen')//購買點數
{}
elseif($phome=='PayToMoney')//存預付款
{}
elseif($phome=='ShopPay')//商城支付
{}
elseif($phome=='BuyGroupPay')//購買充值類型
{}
else
{
printerror('您來自的鏈接不存在','',1,0,1);
}
$user=array();
if($phome=='PayToFen'||$phome=='PayToMoney'||$phome=='BuyGroupPay')
{
$user=islogin();//是否登陸
}
$paytype='tenpay';
$payr=$empire->fetch1("select * from {$dbtbpre}enewspayapi where paytype='$paytype' limit 1");
$bargainor_id=$payr['payuser'];//商戶號
$key=$payr['paykey'];//密鑰
//----------------------------------------------返回信息
import_request_variables("gpc", "frm_");
$strCmdno = $frm_cmdno;
$strPayResult = $frm_pay_result;
$strPayInfo = $frm_pay_info;
$strBillDate = $frm_date;
$strBargainorId = $frm_bargainor_id;
$strTransactionId = $frm_transaction_id;
$strSpBillno = $frm_sp_billno;
$strTotalFee = $frm_total_fee;
$strFeeType = $frm_fee_type;
$strAttach = $frm_attach;
$strMd5Sign = $frm_sign;
//支付驗證
$checkkey="cmdno=".$strCmdno."&pay_result=".$strPayResult."&date=".$strBillDate."&transaction_id=".$strTransactionId."&sp_billno=".$strSpBillno."&total_fee=".$strTotalFee."&fee_type=".$strFeeType."&attach=".$strAttach."&key=".$key;
$checkSign=strtoupper(md5($checkkey));
if($checkSign!=$strMd5Sign)
{
printerror('驗證MD5簽名失敗.','../../../',1,0,1);
}
if($bargainor_id!=$strBargainorId)
{
printerror('錯誤的商戶號.','../../../',1,0,1);
}
if($strPayResult!="0")
{
printerror('支付失敗.','../../../',1,0,1);
}
//----------- 支付成功後處理 -----------
include('../payfun.php');
$pr=$empire->fetch1("select paymoneytofen,payminmoney from {$dbtbpre}enewspublic limit 1");
$orderid=$strSpBillno; //支付訂單
$ddno=$strAttach; //網站的訂單號
$money=$strTotalFee/100;
$fen=floor($money)*$pr[paymoneytofen];
if($phome=='PayToFen')//購買點數
{
$paybz='購買點數: '.$fen;
PayApiBuyFen($fen,$money,$paybz,$orderid,$user[userid],$user[username],$paytype);
}
elseif($phome=='PayToMoney')//存預付款
{
$paybz='存預付款';
PayApiPayMoney($money,$paybz,$orderid,$user[userid],$user[username],$paytype);
}
elseif($phome=='ShopPay')//商城支付
{
include('../../data/dbcache/class.php');
$ddid=(int)getcvar('paymoneyddid');
$paybz='商城購買 [!--ddno--] 的訂單(ddid='.$ddid.')';
PayApiShopPay($ddid,$money,$paybz,$orderid,'','',$paytype);
}
elseif($phome=='BuyGroupPay')//購買充值類型
{
include("../../data/dbcache/MemberLevel.php");
$bgid=(int)getcvar('paymoneybgid');
PayApiBuyGroupPay($bgid,$money,$orderid,$user[userid],$user[username],$user[groupid],$paytype);
}
db_close();
$empire=null;
?>