?? alipay_notify.asp
字號:
<%
'/***************************************************************************************************************
'* FileName: alipay_Notify.asp
'* Description: 本Asp文件為Asp網(wǎng)店集成支付寶最新payto接口的示例代碼,用于接收支付寶傳遞過來反饋通知(買家已付款請賣家發(fā)貨、買家已收到貨物交易結(jié)束、支付寶測試商戶接口是否正常)
'****************************************************************************************************************/
%>
<!--#include file="conn.asp"-->
<%
'定義支付寶通知接口傳遞過來的參數(shù)
Dim msg_id,order_no,gross,buyer_email,buyer_name,buyer_address,buyer_zipcode,buyer_tel,buyer_mobile,action,s_date,ac
Dim returnTxt '返回給支付寶通知接口的結(jié)果
Dim alipayNotifyURL '支付寶查詢接口URL
Dim myalipayEmail '商戶的支付寶Email
Dim Retrieval,ResponseTxt
returnTxt = "Error"
myalipayEmail = "填寫您的支付寶帳號"
'檢查支付寶通知接口傳遞過來的參數(shù)是否合法
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
'事務(wù)處理流程如下:
'1、支付寶通知接口請求該鏈接,并把各參數(shù)傳遞過來
'2、商戶URL頁面接收各參數(shù)并做簡單處理后,調(diào)用支付寶查詢接口,獲得支付寶返回來的true或false結(jié)果,用于判斷是否是支付寶發(fā)過來的請求
'3、根據(jù)支付寶返回來的true結(jié)果,進(jìn)行后臺數(shù)據(jù)處理
'4、處理完成后,把處理結(jié)果反饋給支付寶通知接口
'測試商戶網(wǎng)站URL是否正確安裝
If action = "test" Then
returnTxt = "Y"
'發(fā)貨通知
ElseIf action = "sendOff" Then
returnTxt = "N"
If (ResponseTxt = "true") Or (ResponseTxt = "false") Then
'更新數(shù)據(jù)在商戶系統(tǒng)里的訂單數(shù)據(jù);如果已經(jīng)發(fā)貨,則將returnTxt置為Y,否則為N
'檢查定單狀態(tài)
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
'非法數(shù)據(jù),不做更新
End If
'交易結(jié)束通知
ElseIf action = "checkOut" Then
returnTxt = "Y"
If (ResponseTxt = "true") Or (ResponseTxt = "false") Then
'更新數(shù)據(jù)在商戶系統(tǒng)里的訂單數(shù)據(jù);如果數(shù)據(jù)更新成功,則將returnTxt置為Y,否則為N
'更新數(shù)據(jù)
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
'非法數(shù)據(jù),不做更新
returnTxt = "N"
End If
End If
Response.Write returnTxt
'調(diào)用方法 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
%>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -