Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

code for IPN with paypal

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.  
0
gianitoo
Asked:
gianitoo
  • 2
1 Solution
 
lengreenCommented:
Hi THis is the code i use

 cheers

Len

<%@ 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")
objHttp.open "POST", "http://www.paypal.com/cgi-bin/webscr", 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
      Next

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

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

%>
0
 
lengreenCommented:
have you tried?

cheers

Len
0
 
gianitooAuthor Commented:
i will soon. sory for the delay
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now