<!--#include file="../inc/DAL.asp"-->
<!--#include file="./classes/PayResponseHandler.asp"-->
<!--#include file="config.asp" -->
<%



'---------------------------------------------------------
'财付通即时到帐支付应答（处理回调）示例，商户按照此文档进行开发即可
'---------------------------------------------------------

'创建支付应答对象
Dim resHandler
Set resHandler = new PayResponseHandler
resHandler.setKey(key)

'判断签名
If resHandler.isTenpaySign() = True Then
	
	Dim transaction_id
	Dim total_fee

	'交易单号
	transaction_id = resHandler.getParameter("transaction_id")

	'商品金额,以分为单位
	total_fee = resHandler.getParameter("total_fee")/100
	
	'支付结果
	pay_result = resHandler.getParameter("pay_result")
	
    	'支付信息
	attach = resHandler.getParameter("attach")
	
	If "0" = pay_result Then
	
	'------------------------------
	'处理业务开始
	'------------------------------
	dim lgTPAYsum
	lgTPAYsum=clng(trim(total_fee))*clng(SysConfig("i_Sys_Config_PayPercent"))
	DB_CONN.EXECUTE("update [i_User_Info] set [i_User_Money]=[i_User_Money]+"&lgTPAYsum&"  where [i_User_ID]="&Session(Session_UserID_Arg)&" ")
    RecordConsume2 0,lgTPAYsum,"财付通在线充值 "&clng(total_fee)&"元，收入"&lgTPAYsum,Session(Session_UserID_Arg)
	RWS "location.href='/i/"&SysConfig("i_Sys_Config_TemplatePath")&"/Account.html';"
	REND

if session("bankID")<>"" then
		
		'给付款人发邮件
attach=split(attach,"|") ' 以,为拆分关键字	
pay_qq=attach(0)
pay_phone=attach(1)
pay_work_type=attach(2)
email=attach(3)

FRecipient =email'收件人EMai
FRecipientName=pay_phone
paytime=now()


'Send Email
mess="<html><body><font color=""red"">QQ号码:"&pay_qq&"<br>联系电话:"&pay_phone&"<br>支付金额:"&total_fee&"<br>服务项目:"&pay_work_type&"<br> 付款时间:"&paytime&"</font><br>" 

Set JMail = Server.CreateObject("JMail.Message") 
'是否将信头编码成iso-8859-1字符集. 缺省是True 
JMail.ISOEncodeHeaders = True 
'如果JMail.silent设置为true,ErrorCode包含的是错误代码 
JMail.Silent = True 
'设置标题和内容编码，如果标题有中文，必须设定编码为gb2312 
JMail.Charset = "gb2312" 
'JMail.ContentType = "text/html" '如果发内嵌附件一定要注释掉这行，重要！ 
JMail.From = FEmail ' 发送者地址 
JMail.FromName = FName ' 发送者姓名 
JMail.MailServerUserName =FUserName ' 身份验证的用户名 
JMail.MailServerPassword = FPassword ' 身份验证的密码 
 
'加入新的收件人 
JMail.AddRecipient FRecipient, FRecipientName 
JMail.Subject = pay_phone&"的付款信息" 
JMail.Body = "付款信息." 
JMail.HTMLBody = mess
JMail.appendHTML "<br></body></html>" 

'如果对方信箱不支持HTML格式邮件，我们仍需要给他一个友善的提示 
' But as not all mailreaders are capable of showing HTML emails 
' we will also add a standard text body 
JMail.Body = "Too bad you can't read HTML-mail." 
JMail.appendText " There would have been a nice picture for you" 

JMail.Send(SServer) 
JMail.Close() 
Set JMail = Nothing 

session("bankID")=""
end if


		'注意交易单不要重复处理
		'注意判断返回金额
		
		'------------------------------
		'处理业务完毕
		'------------------------------	
		
		'调用doShow
		session("mess")=mess
		session("pay_phone")=pay_phone	


	
		resHandler.doShow(show_url)
	
	Else
		'当做不成功处理
		Response.Write("支付失败")
	End If	

Else

	'签名失败
	Response.Write("签名签证失败")



End If


%>