⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alipay_notify.asp

📁 在线购物模块:在线购物系统必须具备的功能模块中
💻 ASP
字号:
<%
'/***************************************************************************************************************
	'* FileName:	alipay_Notify.asp
	'* Description:	本Asp文件为Asp网店集成支付宝最新payto接口的示例代码,用于接收支付宝传递过来反馈通知(买家已付款请卖家发货、买家已收到货物交易结束、支付宝测试商户接口是否正常)
'****************************************************************************************************************/
%>
<!--#include file="conn.asp"-->


<%
	'定义支付宝通知接口传递过来的参数
	Dim msg_id,order_no,gross,buyer_email,buyer_name,buyer_address,buyer_zipcode,buyer_tel,buyer_mobile,action,s_date,ac
	
	Dim returnTxt		'返回给支付宝通知接口的结果
	Dim alipayNotifyURL	'支付宝查询接口URL
	Dim myalipayEmail	'商户的支付宝Email
	Dim Retrieval,ResponseTxt
	
	returnTxt			= "Error"
	alipayNotifyURL		= "http://notify.alipay.com/trade/notify_query.do?"
	myalipayEmail		= "填写您的支付宝账号"

	
	'检查支付宝通知接口传递过来的参数是否合法
	msg_id			= DelStr(Request("msg_id"))
	order_no		= DelStr(Request("order_no"))
	gross			= DelStr(Request("gross"))
	buyer_email		= DelStr(Request("buyer_email"))
	buyer_name		= DelStr(Request("buyer_name"))
	buyer_address	= DelStr(Request("buyer_address"))
	buyer_zipcode	= DelStr(Request("buyer_zipcode"))
	buyer_tel		= DelStr(Request("buyer_tel"))
	buyer_mobile	= DelStr(Request("buyer_mobile"))
	action			= DelStr(Request("action"))
	s_date			= DelStr(Request("date"))
	ac				= DelStr(Request("ac"))

	alipayNotifyURL	= alipayNotifyURL & "msg_id=" & msg_id & "&email=" & myalipayEmail & "&order_no=" & order_no
	
	Set Retrieval  = Server.CreateObject("Microsoft.XMLHTTP") 
        
        
        Retrieval.open "GET", alipayNotifyURL, False, "", "" 
        Retrieval.send()
        
        ResponseTxt = Retrieval.ResponseText
	Set Retrieval = Nothing

	'事务处理流程如下:
	'1、支付宝通知接口请求该链接,并把各参数传递过来
	'2、商户URL页面接收各参数并做简单处理后,调用支付宝查询接口,获得支付宝返回来的true或false结果,用于判断是否是支付宝发过来的请求
	'3、根据支付宝返回来的true结果,进行后台数据处理
	'4、处理完成后,把处理结果反馈给支付宝通知接口

	'测试商户网站URL是否正确安装
	If action = "test" Then
		returnTxt	= "Y"

	'发货通知
	ElseIf action = "sendOff" Then
		returnTxt		= "N"
		If (ResponseTxt = "true") Or (ResponseTxt = "false") Then
			'更新数据在商户系统里的订单数据;如果已经发货,则将returnTxt置为Y,否则为N
			'检查定单状态
			

			set status=server.CreateObject("adodb.recordset")
			status.open "update  orders set state=5 where goods='"&trim(order_no)&"' ",conn,1,3
			
			set status=nothing
			returnTxt= "Y"
		Else
			'非法数据,不做更新
		End If
	
	'交易结束通知
	ElseIf action = "checkOut" Then
		returnTxt	= "Y"
		If (ResponseTxt = "true") Or (ResponseTxt = "false") Then
			'更新数据在商户系统里的订单数据;如果数据更新成功,则将returnTxt置为Y,否则为N
			'更新数据
			
			set status=server.CreateObject("adodb.recordset")
			status.open "update  orders set state=6 where goods='"&trim(order_no)&"' ",conn,1,3
			returnTxt= "Y"
			
			set status=nothing
		Else
			'非法数据,不做更新
			returnTxt	= "N"
		End If

	End If

	Response.Write returnTxt
	

	'调用方法 DelStr(值),防止SQL注入攻击
	Function DelStr(Str)
		If IsNull(Str) Or IsEmpty(Str) Then
			Str	= ""
		End If
		DelStr	= Replace(Str,";","")
		DelStr	= Replace(DelStr,"'","")
		DelStr	= Replace(DelStr,"&","")
		DelStr	= Replace(DelStr," ","")
		DelStr	= Replace(DelStr," ","")
		DelStr	= Replace(DelStr,"%20","")
		DelStr	= Replace(DelStr,"--","")
		DelStr	= Replace(DelStr,"==","")
		DelStr	= Replace(DelStr,"<","")
		DelStr	= Replace(DelStr,">","")
		DelStr	= Replace(DelStr,"%","")
	End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -