【发布时间】:2012-04-26 09:46:20
【问题描述】:
{Following is the vb.net code for IPN listener:
If Me.TestMode = True Then
Me.RequestUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr"
Else
Me.RequestUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr" '"https://www.paypal.com/cgi-bin/webscr"
End If
'====================================Test======================================'
Dim startTime As String = String.Format("{0:MM-dd-yyyy hh:mm:ss:tt}", Now)
'=============================================================================='
Dim req As HttpWebRequest = CType(WebRequest.Create(Me.RequestUrl), HttpWebRequest)
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim Param() As Byte = HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String = Encoding.ASCII.GetString(Param)
strRequest = strRequest & "&cmd=_notify-validate"
req.ContentLength = strRequest.Length
' Dim pairs() As String = strRecieved.Split("&")
Using streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest.ToString)
streamOut.Close()
End Using
Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String = streamIn.ReadToEnd()
streamIn.Close()
WriteLog(strResponse)
我已经在 vb.net 中完成了 paypal IPN 监听器的代码。当我使用 paypal 沙盒帐户测试该 url 时,它显示以下消息: “IPN发送成功。” 但是当我在服务器上检查我的日志文件时,它会显示来自贝宝沙箱 url 的无效响应。如果没有 VALID 响应,我的其他代码将无法工作。 请帮忙!!
【问题讨论】:
-
IPN 消息会在 paypal 交易发生任何事件时发送。 ipn 消息出现“IPN 成功发送”的方式和位置。
-
当我用贝宝沙盒模拟器测试它时。当时我收到“IPN 成功发送”消息。
-
在paypal沙箱上做一个测试交易,这样paypal就会给你发送有效状态的ipn响应。
-
当我在将控制权从我的网站迁移到贝宝时指定“notify_url(IPN url here)”时它开始工作。但是通过这样做,我得到了 payment_status=pending,虽然我已经付款了。你能帮我解决这个问题吗?
-
我正在发布代码,它可以帮助您生成 paypal 支付链接,一旦交易完成,您将得到正确的 ipn 响应。
标签: vb.net paypal-ipn