I am having a problem with PayPal IPN response. After payment is made by the customer, PayPal IPN returns this URL:
www.mywebsite.com?orderid=32&tx=2AC67201DL3533325&st=Pending&amt=2.50&cc=USD&cm=&item_number=32
There are a couple of issues
- Post-back field names are undefined or missing. Thus I can get the INVALID message. I am not sure if my website does not read POST variables. When I looked at IPN history, it shows that each IPN has been sent with the complete url.
- Payment status keeps coming Pending. Does this issue cause the first issue?
Thank you for your responses in advance.
Here is the code:
Dim strSandbox As String, strLive As String
Dim req As HttpWebRequest
strSandbox = "http://www.sandbox.paypal.com/cgi-bin/webscr/"
strLive = "https://www.paypal.com/cgi-bin/webscr"
req = CType(WebRequest.Create(strSandbox), HttpWebRequest)
'Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim param() As Byte
param = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String
strRequest = Encoding.ASCII.GetString(param)
strRequest = strRequest & "&cmd=_notify-validate"
req.ContentLength = strRequest.Length
'Response.Write(strRequest)
'Send the request to PayPal and get the response
Dim streamOut As StreamWriter
streamOut = New StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Close()
Dim streamIn As StreamReader
streamIn = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String
strResponse = streamIn.ReadToEnd()
Response.Write(strResponse)
streamIn.Close()
If (strResponse = "VERIFIED") Then
Response.Redirect("thankyou.aspx")
ElseIf (strResponse = "INVALID") Then
End If