%@LANGUAGE="VBScript"%> <% Dim Item_name, Item_number, Payment_status, Payment_amount Dim Txn_id, Receiver_email, Payer_email Dim objHttp, str Dim crlf Dim decyn crlf=chr(13)+chr(10) ' 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") objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded" objHttp.Send str Set JMail = Server.CreateObject("JMail.SMTPMail") ' Below you should enter your own SMTP-server JMail.ServerAddress = "smtp.rumach.com" JMail.Sender = "ipn@megascotland.co.uk" JMail.ReplyTo= "angus@rumach.com" JMail.Subject = "ipn " + trim(objHttp.responseText) + " " + trim(Request.Form("Payment_status"))+ " "+ trim(objHttp.status) JMail.AddRecipient "angus@rumach.com" bdy="" max_items=Cint(Request.Form("num_cart_items")) 'set loop counter to number of items in the cart (not qty of items) for inum = 1 to max_items qt="quantity"+Cstr(inum) itn="item_name"+Cstr(inum) if (Request.Form(qt) > 0) then bdy=bdy + Request.Form(itn) + " " + Request.Form(qt) +crlf +crlf next JMail.Body = bdy + "__________________________________________________"+crlf+crlf +request.form+crlf + "__________________________________________________" JMail.Priority = 3 JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR") JMail.Logging = True JMail.Execute ' Check notification validation if (objHttp.status <> 200 ) then ' HTTP error handling 'elseif (objHttp.responseText = "VERIFIED") then elseif (10 > 3) then dim conn, strsql, rsuser, strMDBPath 'initialise objects and variables set conn=server.createobject("ADODB.Connection") set rsuser=server.createobject("ADODB.Recordset") set conn2=server.createobject("ADODB.Connection") set rsuser2=server.createobject("ADODB.Recordset") conn2.open GetStockConnStr 'check to see if current txn_id exists already strsql2 = "SELECT * FROM log where txn_id='"+trim(Request.Form("txn_id"))+"'" 'strsql2 = "SELECT * FROM log" rsuser2.CursorType = 2 'Set the cursor type we are using so we can navigate through the recordset rsuser2.LockType = 3 'Set the lock type so that the record is locked by ADO when it is updated rsuser2.open strsql2, conn2 if (rsuser2.eof) Then 'transaction record not allready used decyn=True 'reset decrement flag conn.open GetStockConnStr rsuser.CursorType = 2 'Set the cursor type we are using so we can navigate through the recordset rsuser.LockType = 3 'Set the lock type so that the record is locked by ADO when it is updated for inum = 1 to max_items qt="quantity"+Cstr(inum) itn="item_number"+Cstr(inum) if cInt(Request.Form(qt)) > 0 then strsql = "SELECT * FROM stock where item='"+trim(Request.Form(itn))+"'" rsuser.open strsql, conn if not rsuser.eof Then rsuser("stock") = rsuser("Stock") - cInt(Request.Form(qt)) rsuser.Update else decyn=false end if rsuser.close end if next else decyn=false 'reset decrement flag 'JMail.Subject = "do nothing " 'JMail.Execute end if '================================= 'Log all what is submitted '================================= Dim formdata FormData="" IF request.Form.Count > 0 THEN FOR i = 1 TO request.Form.Count formdata = formdata + request.Form.Key(i)+"="+request.Form.Item(i) +"&" NEXT END IF rsuser.CursorType = 2 'Set the cursor type we are using so we can navigate through the recordset rsuser.LockType = 3 'Set the lock type so that the record is locked by ADO when it is updated strSQL = "SELECT * FROM log" rsuser.open strSQL, conn rsuser.addnew rsuser("trans")=formdata rsuser("date")=FormatDateTime(now(),0) rsuser("txn_id")=Request.Form("txn_id") if decyn then rsuser("StockDec")="-" else rsuser("StockDec")=" " end if 'Write the updated recordset to the database rsuser.Update 'close resources used rsuser.close conn.close rsuser2.close conn2.close 'clean up set rsuser=nothing set conn=nothing set rsuser2=nothing set conn2=nothing 'debug use only 'JMail.Subject = "Debug: End of database update" 'JMail.Execute elseif (objHttp.responseText = "INVALID") then ' error else ' error end if set objHttp = nothing %>