{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 响应,我的其他代码将无法工作。请帮忙!!