提问人:mark davies 提问时间:6/5/2020 最后编辑:Preston PHXmark davies 更新时间:6/5/2020 访问量:100
当有人在Ebay上向我付款时,我网站上的PayPal IPN侦听器开始抛出Guid错误
PayPal IPN Listener on my website has started throwing a Guid error when someone pays me on Ebay
问:
下面是我的IPN侦听器,它在我的网站上一直运行良好,用于客户PayPal付款。它以 Guid 格式(32 位数字和 4 个破折号)为我的网站设置订单。但是,我使用相同的 PayPal 帐户进行 Ebay 销售,并且我刚刚出售了一件商品,该商品在付款时导致以下错误:
System.FormatException
Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
在 IPN 历史记录中,“付款状态”为“已完成”,但 HTTP 响应代码为 500,“传递状态”为“正在重试”。我收到了来自 PayPal 的电子邮件警告,这让我很担心,因为我的网站需要 IPN。
我已经检查了 Ebay 交易并且“自定义”EBAY_ENSDX00001030330553110,所以我猜我的 IPN 代码不喜欢这样。有没有办法让 Ebay 交易远离 PayPal 中的 IPN 侦听器?或者有没有办法在下面编辑我的 IPN 代码来处理不是 32 位格式的自定义 ID?
IPN 侦听器..
Imports System.Net
Imports System.IO
Imports System.Net.Cache
Partial Class IPNListener
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Post back to either sandbox or live
'Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
Dim strLive As String = "https://ipnpb.paypal.com/cgi-bin/webscr"
'SSL Error Code
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim req As HttpWebRequest = CType(WebRequest.Create(strLive), HttpWebRequest)
'Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String = Encoding.ASCII.GetString(Param)
strRequest = strRequest + "&cmd=_notify-validate"
req.ContentLength = strRequest.Length
'Send the request to PayPal and get the response
Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Close()
Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String = streamIn.ReadToEnd()
streamIn.Close()
Dim qscoll As NameValueCollection = HttpUtility.ParseQueryString(strRequest)
'Insert the paypal response
Dim order As New orders
order.InsertPaypalResponse(qscoll("txn_id"), qscoll("custom"), strRequest)
If strResponse = "VERIFIED" Then
order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
ElseIf strResponse = "INVALID" Then
'log for manual investigation
order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
Else
'Response wasn't VERIFIED or INVALID, log for manual investigation
order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), "ERROR")
End If
End Sub
End Class
答:
1赞
Preston PHX
6/5/2020
#1
在 EBAY 交易的情况下,您只需跳过验证并成功退出,因为您不需要对它执行任何操作。
PayPal 需要您做的就是返回 HTTP 200,以便他们可以将 IPN 标记为已成功交付。(问题是您当前返回HTTP 500或类似版本,导致PayPal将交付标记为失败。
另一种解决方案是在网站的交易级别将您网站的notify_url指定为每笔交易的 API 设置(如果没有 API,则为 HTML 重定向)中的参数,这将覆盖您PayPal帐户中的任何设置(或缺少设置)。然后,在您的 PayPal 帐户中,您可以清空 IPN 侦听器 URL,您将不会再获得 Ebay 交易的任何 IPN。
评论
0赞
mark davies
6/5/2020
非常感谢,这真的很有帮助。我还在学习这一切......我会在 Dim order As New orders 之前放置一个 IF 语句吗?最好的检查是什么?我猜:如果 LEN(qscoll(“custom”)) =36 那么......
0赞
Preston PHX
6/5/2020
我不一定会根据习俗来决定。如果自定义> 32,则可以,但有效负载中可能有更好的变量需要检查。
0赞
mark davies
6/5/2020
感谢您的帮助。我已将 IF LEN(qscoll(“custom”)) >= 32 THEN 添加到我的 IPN 中,看看效果如何。如果我遇到任何问题,我会做Notify_Url的事情。谢谢,谢谢。
评论