<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> 
<!--#include file="../../inc/payok.asp"-->
<!-- #include file="md5.asp" -->

<%
key=toparkey("qqkey")

pay_result=request("pay_result")   		 '0成功
ver=request("ver")  				
charset=request("charset")  			
pay_info=request("pay_info") 			 '支付成功 为空
transaction_id=request("transaction_id") '财付通订单号 
sp_billno=request("sp_billno")         	 '商户订单号
total_fee=request("total_fee")          '金额
fee_type=request("fee_type")    
bargainor_id=request("bargainor_id")     '商户号
attach=request("attach")   				  '原路返回
sign=request("sign") 
bank_type=request("bank_type") 
bank_billno=request("bank_billno")       '银行订单号
time_end=request("time_end")      		 '完成时间
purchase_alias=request("purchase_alias") '买家姓名
sign_sp_id=request("sign_sp_id")
	
	Response.Write("success")
	
	
	signstr="attach="&attach
	if bank_billno<>"" then	signstr=signstr&"&bank_billno="&bank_billno
	if bank_type<>"" then signstr=signstr&"&bank_type="&bank_type
	if bargainor_id<>"" then signstr=signstr&"&bargainor_id="&bargainor_id
	if charset<>"" then	signstr=signstr&"&charset="&charset
	if fee_type<>"" then signstr=signstr&"&fee_type="&fee_type
	if pay_info<>"" then signstr=signstr&"&pay_info="&pay_info
	if pay_result<>"" then signstr=signstr&"&pay_result="&pay_result
	if purchase_alias<>"" then signstr=signstr&"&purchase_alias="&purchase_alias
	if sign_sp_id<>"" then signstr=signstr&"&sign_sp_id="&sign_sp_id
	if sp_billno<>"" then signstr=signstr&"&sp_billno="&sp_billno
	if time_end<>"" then signstr=signstr&"&time_end="&time_end
	if total_fee<>"" then signstr=signstr&"&total_fee="&total_fee
	if transaction_id<>"" then signstr=signstr&"&transaction_id="&transaction_id
	if ver<>"" then	signstr=signstr&"&ver="&ver
	signstr=signstr&"&key="&key
	sign2=MD5(signstr)
	sign2=UCase(sign2)


If sign=sign2 Then

			pay_body=attach
			out_trade_no=sp_billno
			trade_no=transaction_id
			tstatus=pay_result	
			trade_status=pay_result

conn.Execute("Insert Into aypayhuitiao(aypaydd,aypaytd,aypayfyu,aypayyu,aypaycon) values('"&out_trade_no&"','QQ官方','"&request.ServerVariables("SERVER_NAME")&"','"&request.ServerVariables("HTTP_REFERER")&"','"&request.QueryString&"')")
	



			if int(pay_result)=0  then
		
			'执行开始***************************************************************************
			if pay_body="buy" then
			call payokbuy(out_trade_no,trade_no,total_fee,"no")	
			end if
		
			if pay_body="chongzhi" then
			call payokchong(out_trade_no,trade_no,total_fee,"no")
			end if
			'执行结束***************************************************************************

			
			
		
			Else
			'Response.write "失败"
			Response.end
			end if




Else
Response.write "信息被篡改!"
Response.end
end if



%>