{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)
I have done code for paypal IPN listener in vb.net . When I test that url with paypal sandbox account, it shows following message:
“IPN successfully sent.”
But when I check my log file on server, then it shows INVALID response from paypal sandbox url. Without VALID response my other code will not work.
Please help!!
Generate paypal transaction like e.g buy now button via vb.net
Generate paypal link, when you click on link, you will be redirect to paypal sandbox or live link. once you complete transaction, you will be redirected to website back and within background paypal will send transaction event via ipn.
Hope you will receive proper ipn response.