<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>  
<!--#include file="../../inc/payok.asp"--> 
<!--#include file="../../inc/md52.asp"--> 
<% 
Response.Charset = "utf-8"

On error resume next 

key=toparkey("skey")

Response.Write "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> "



    set xml_dom = Server.CreateObject("MSXML2.DOMDocument")
	xml_dom.resolveExternals = false
    xml_dom.load request 
	
	sign=xml_dom.getelementsbytagname("sign").item(0).text 
	
	appid=xml_dom.getelementsbytagname("appid").item(0).text 
	attach=xml_dom.getelementsbytagname("attach").item(0).text 					
	bank_type=xml_dom.getelementsbytagname("bank_type").item(0).text 
	cash_fee=xml_dom.getelementsbytagname("cash_fee").item(0).text 
	cash_fee_type=xml_dom.getelementsbytagname("cash_fee_type").item(0).text
	coupon_count=xml_dom.getelementsbytagname("coupon_count").item(0).text 
	coupon_fee=xml_dom.getelementsbytagname("coupon_fee").item(0).text 
	coupon_fee_0=xml_dom.getelementsbytagname("coupon_fee_0").item(0).text 
	coupon_fee_1=xml_dom.getelementsbytagname("coupon_fee_1").item(0).text 
	coupon_id_0=xml_dom.getelementsbytagname("coupon_id_0").item(0).text 
	coupon_id_1=xml_dom.getelementsbytagname("coupon_id_1").item(0).text 
	coupon_type_0=xml_dom.getelementsbytagname("coupon_type_0").item(0).text 
	coupon_type_1=xml_dom.getelementsbytagname("coupon_type_1").item(0).text 
	device_info=xml_dom.getelementsbytagname("device_info").item(0).text 
	err_code=xml_dom.getelementsbytagname("err_code").item(0).text 	
	err_code_des=xml_dom.getelementsbytagname("err_code_des").item(0).text 
	fee_type=xml_dom.getelementsbytagname("fee_type").item(0).text 		
	is_subscribe=xml_dom.getelementsbytagname("is_subscribe").item(0).text 	
	mch_id=xml_dom.getelementsbytagname("mch_id").item(0).text 			
	nonce_str=xml_dom.getelementsbytagname("nonce_str").item(0).text 	
	openid=xml_dom.getelementsbytagname("openid").item(0).text 				
	out_trade_no=xml_dom.getelementsbytagname("out_trade_no").item(0).text 	
	result_code=xml_dom.getelementsbytagname("result_code").item(0).text 
	return_code=xml_dom.getelementsbytagname("return_code").item(0).text 
	return_msg	=xml_dom.getelementsbytagname("return_msg").item(0).text 
	settlement_total_fee=xml_dom.getelementsbytagname("settlement_total_fee").item(0).text 
	sign_type=xml_dom.getelementsbytagname("sign_type").item(0).text 
	time_end=xml_dom.getelementsbytagname("time_end").item(0).text 		
	total_fee=xml_dom.getelementsbytagname("total_fee").item(0).text 	
	trade_type=xml_dom.getelementsbytagname("trade_type").item(0).text 			
	transaction_id=xml_dom.getelementsbytagname("transaction_id").item(0).text


	
	aaa="appid="&appid&"&"
	if attach<>"" then aaa=aaa&"attach="&attach&"&"
	if bank_type<>"" then aaa=aaa&"bank_type="&bank_type&"&"
	if cash_fee<>"" then aaa=aaa&"cash_fee="&cash_fee&"&"
	if cash_fee_type<>"" then aaa=aaa&"cash_fee_type="&cash_fee_type&"&"
	if coupon_count<>"" then aaa=aaa&"coupon_count="&coupon_count&"&"
	if coupon_fee<>"" then aaa=aaa&"coupon_fee="&coupon_fee&"&"
	if coupon_fee_0<>"" then aaa=aaa&"coupon_fee_0="&coupon_fee_0&"&"
	if coupon_fee_1<>"" then aaa=aaa&"coupon_fee_1="&coupon_fee_1&"&"
	if coupon_id_0<>"" then aaa=aaa&"coupon_id_0="&coupon_id_0&"&"
	if coupon_id_1<>"" then aaa=aaa&"coupon_id_1="&coupon_id_1&"&"
	if coupon_type_0<>"" then aaa=aaa&"coupon_type_0="&coupon_type_0&"&"
	if coupon_type_1<>"" then aaa=aaa&"coupon_type_1="&coupon_type_1&"&"
	if device_info<>"" then aaa=aaa&"device_info="&device_info&"&"
	if err_code<>"" then aaa=aaa&"err_code="&err_code&"&"
	if err_code_des<>"" then aaa=aaa&"err_code_des="&err_code_des&"&"
	if fee_type<>"" then aaa=aaa&"fee_type="&fee_type&"&"
	if is_subscribe<>"" then aaa=aaa&"is_subscribe="&is_subscribe&"&"
	if mch_id<>"" then aaa=aaa&"mch_id="&mch_id&"&"
	if nonce_str<>"" then aaa=aaa&"nonce_str="&nonce_str&"&"
	if openid<>"" then aaa=aaa&"openid="&openid&"&"
	if out_trade_no<>"" then aaa=aaa&"out_trade_no="&out_trade_no&"&"
	if result_code<>"" then aaa=aaa&"result_code="&result_code&"&"
	if return_code<>"" then aaa=aaa&"return_code="&return_code&"&"
	if return_msg<>"" then aaa=aaa&"return_msg="&return_msg&"&"
	if settlement_total_fee<>"" then aaa=aaa&"settlement_total_fee="&settlement_total_fee&"&"
	if sign_type<>"" then aaa=aaa&"sign_type="&sign_type&"&"
	if time_end<>"" then aaa=aaa&"time_end="&time_end&"&"
	if total_fee<>"" then aaa=aaa&"total_fee="&total_fee&"&"
	if trade_type<>"" then aaa=aaa&"trade_type="&trade_type&"&"
	if transaction_id<>"" then aaa=aaa&"transaction_id="&transaction_id&"&"
	aaa=aaa&"key="&key
	bbb=UCase(md5(aaa))

	'set fs= createobject("scripting.filesystemobject")
	'set ts=fs.OpenTextFile(Server.MapPath("native_call.log"), 8, true)
	'ts.writeline(aaa)
	'ts.close
	'set ts=fs.OpenTextFile(Server.MapPath("native_call.log"), 8, true)
	'ts.writeline(sign)
	'ts.close
	'set ts=fs.OpenTextFile(Server.MapPath("native_call.log"), 8, true)
	'ts.writeline(bbb)
	'ts.close

	'rs.open "select * from ayceshibz",conn,1,3
	'rs.addnew
	'rs("aybz1")=aaa
	'rs("aybz2")=sign
	'rs("aybz3")=bbb
	'rs("aybz4")=str
	'rs.update
	'rs.close

				
if sign=bbb and result_code="SUCCESS" then

		trade_no = transaction_id
		pay_body = attach
		total_fee=total_fee/100

conn.Execute("Insert Into aypayhuitiao(aypaydd,aypaytd,aypayfyu,aypayyu,aypaycon) values('"&out_trade_no&"','微信官方H5','"&request.ServerVariables("SERVER_NAME")&"','"&request.ServerVariables("HTTP_REFERER")&"','"&aaa&"')")
	
	
		'执行开始***************************************************************************
		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
		'执行结束***************************************************************************

end if	
	

%>