PAYPAL IPN Response Problem

Posted by Gorkem Tolan on Stack Overflow See other posts from Stack Overflow or by Gorkem Tolan
Published on 2010-04-17T16:34:35Z Indexed on 2010/04/17 16:43 UTC
Read the original article Hit count: 274

Filed under:

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 1- Postback 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. 2- 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

© Stack Overflow or respective owner

Related posts about paypal-sandbox