code for IPN with paypal

Posted on 2004-11-05
Last Modified: 2008-03-10
could you send me sample code on how to update my database after somebody paid through paypal  so i can confirm if the payment was made.  
Question by:gianitoo
    LVL 10

    Accepted Solution

    Hi THis is the code i use



    <%@ LANGUAGE="VBSCRIPT" LCID="2057"%>      


    Dim authToken, txToken
    Dim query
    Dim objHttp
    Dim sQuerystring
    Dim sParts, iParts, aParts
    Dim sResults, sKey, sValue
    Dim i, result
    Dim Firstname, lastName, itemName, mcGross, mcCurrency

    authToken = "3Tw9HrVeMy0Xp_BfbcxXoGS_LapSKlwhdgfdfgdfggjfi04_Ob1XMF0CtfmTGE_gtzFbp8WS" '  your token
    txToken = Request.Querystring("tx")

    query = "cmd=_notify-synch&tx=" & txToken &"&at=" & authToken

    set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
    ' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") "POST", "", false
    objHttp.Send query

    sQuerystring = objHttp.responseText

    If Mid(sQuerystring,1,7) = "SUCCESS" Then
          sQuerystring = Mid(sQuerystring,9)
          sParts = Split(sQuerystring, vbLf)
          iParts = UBound(sParts) - 1
          ReDim sResults(iParts, 1)
          For i = 0 To iParts
                aParts = Split(sParts(i), "=")
                sKey = aParts(0)
                sValue = aParts(1)
                sResults(i, 0) = sKey
                sResults(i, 1) = sValue
                Select Case sKey
                      Case "first_name"
                      Firstname = sValue
                      Case "last_name"
                      lastName = sValue
                      Case "item_name"
                      itemName = sValue
                      Case "mc_gross"
                      mcGross = sValue
                      Case "mc_currency"
                      mcCurrency = sValue
                End Select

          Response.Write("<p><h3>Your order has been received.</h3></p>")
          Response.Write("<li>Name: " & Firstname & " " & lastName & "</li>")
          Response.Write("<li>Description: " & itemName & "</li>")
          Response.Write("<li>Amount: " & mcCurrency & " " & mcGross & "</li>")

          set Recordset1 = Server.CreateObject("ADODB.Recordset")      
          strQuery = "your update query"
          With Recordset1
                .ActiveConnection = strDBCONN
                .Source = strQuery
                .CursorType = 1
                .CursorLocation = 2
                .LockType = 3
          End With
          if not Recordset1.EOF then
                response.write "Payment Accepted but could not complete account update " & Recordset1(0)
          end if
          'log for manual investigation
    End If

    LVL 10

    Expert Comment

    have you tried?


    LVL 1

    Author Comment

    i will soon. sory for the delay

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now