Hi
The following code works in sandbox but not live the ipn message reads as sent and returns a 200 message so I presume this works ok.
the database is not updated though but is when in sandbox. I havent installed msxml would this make a differenc as the ipn message completes with a 200 message
<%@LANGUAGE="VBScript"%><%dim ipnok ipnok="no" %><% Dim Item_name, Item_number, Payment_status, Payment_amount Dim Txn_id, Receiver_email, Payer_email Dim objHttp, str ' read post from PayPal system and add 'cmd' str = Request.Form & "&cmd=_notify-validate" ' post back to PayPal system to validate set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") ' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0") ' set objHttp = Server.CreateObject("Microsoft.XMLHTTP") objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded" objHttp.Send str ' assign posted variables to local variables Item_name = Request.Form("item_name") Item_number = Request.Form("item_number") Payment_status = Request.Form("payment_status") Payment_amount = Request.Form("mc_gross") Payment_currency = Request.Form("mc_currency") Txn_id = Request.Form("txn_id") Receiver_email = Request.Form("receiver_email") Payer_email = Request.Form("payer_email") ' Check notification validation if (objHttp.status <> 200 ) then ' HTTP error handling elseif (objHttp.responseText = "VERIFIED") then ipnok="yes" ' check that Payment_status=Completed ' check that Txn_id has not been previously processed ' check that Receiver_email is your Primary PayPal email ' check that Payment_amount/Payment_currency are correct ' process payment elseif (objHttp.responseText = "INVALID") then ' log for manual investigation else ' error end if set objHttp = nothing %><% if ipnok="yes" then%><% 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsUpdateEntry 'Holds the recordset for the record to be updated Dim strSQL 'Holds the SQL query to query the database Dim lngRecordNo 'Holds the record number to be updated 'Read in the record number to be updated if Request.Form("item_number")=("") then Response.End end if lngRecordNo = CLng(Request.Form("item_number")) 'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using a DSN-less connection adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database.mdb") 'Set an active connection to the Connection object using DSN connection 'adoCon.Open "DSN=guestbook" 'Create an ADO recordset object Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT * FROM tbl WHERE N_ID=" & lngRecordNo 'Set the cursor type we are using so we can navigate through the recordset rsUpdateEntry.CursorType = 2 'Set the lock type so that the record is locked by ADO when it is updated rsUpdateEntry.LockType = 3 'Open the recordset with the SQL query rsUpdateEntry.Open strSQL, adoCon 'Update the record in the recordset rsUpdateEntry.Fields("N_av") = "(Sold)" 'Write the updated recordset to the database rsUpdateEntry.Update 'Reset server objects rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set adoCon = Nothing 'Return to the update select page in case another record needs deleting Response.End %> <% elseif ipnok="no" then Response.End %><%else%><%end if%>
↧
paypal ipn works in sandbox but not live?
↧