最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
支付宝接口代码 四
时间:2022-07-02 23:17:18 编辑:袖梨 来源:一聚教程网
支付宝接口代码 支付宝接口程序 支付宝接口 支付宝代码 支付宝接口 php 支付宝 接口 文档 网站支付宝接口 最新支付宝接口 支付宝接口源码 支付宝接口说明
下面是一个事例,可以参考一下.
<%
'/***************************************************************************************************************
'* FileName: alipay_Notify.asp
'* Description: 本Asp文件为Asp网店集成支付宝最新payto接口的示例代码,用于接收支付宝传递过来反馈通知(买家已付款请卖家发货、买家已收到货物交易结束、支付宝测试商户接口是否正常)
'****************************************************************************************************************/
%>
<%
'定义支付宝通知接口传递过来的参数
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
%>
好了就讲完了,有不足之处请指点.
相关文章
- 《流放之路2》寻找熔炉任务攻略分享 12-23
- 《流放之路2》德雷文打法技巧分享 12-23
- 《流放之路2》永恒裁判者德雷文具体位置介绍 12-23
- 未定事件簿夏彦归路沿风怎么样 12-23
- 未定事件簿左然墨望书怎么样 12-23
- 桃源深处有人家冬至阳生怎么玩 12-23