【发布时间】:2021-07-13 07:00:51
【问题描述】:
尝试对一些旧的 Classic ASP Paypal IPN 代码进行故障排除。遗留代码非常适合销售产品。但是,从 Paypal 帐户处理 REFUND 似乎会导致 Paypal IPN 出现一些问题。 IPN 监听器接收到 Refund IPN 消息并正确处理业务逻辑,将交易标记为 Refunded。但是,由于某种原因,Paypal 仍然将交易 IPN 历史记录为“重试”。下面是来自 GitHub 的示例代码,用于创建我们正在排除故障的 IPN 侦听器。
对于销售和退款,返回到 Paypal 的帖子是否需要不同?
非常感谢任何帮助。干杯
<%@LANGUAGE="VBScript"%>
<%
Dim Item_name, Item_number, Payment_status, Payment_amount
Dim Txn_id, Receiver_email, Payer_email
Dim objHttp, str
' read post from PayPal system and add 'cmd'
str = Request.Form & "&cmd=_notify-validate"
' post back to PayPal system to validate
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
' set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
' assign posted variables to local variables
Item_name = Request.Form("item_name")
Item_number = Request.Form("item_number")
Payment_status = Request.Form("payment_status")
Payment_amount = Request.Form("mc_gross")
Payment_currency = Request.Form("mc_currency")
Txn_id = Request.Form("txn_id")
Receiver_email = Request.Form("receiver_email")
Payer_email = Request.Form("payer_email")
' Check notification validation
if (objHttp.status <> 200 ) then
' HTTP error handling
elseif (objHttp.responseText = "VERIFIED") then
' check that Payment_status=Completed and other variables
Execute business process code, mark transaction Completed or Refunded from payment_status works successfully
elseif (objHttp.responseText = "INVALID") then
' log for manual investigation
else
' error
end if
set objHttp = nothing%>
【问题讨论】: