<% Dim Item_name, Item_number, Payment_status, Payment_amount Dim Txn_id, Receiver_email, Payer_email Dim objHttp, str dim objSendmail ' 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.paypal.com/cgi-bin/webscr", false objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded" objHttp.Send str ' Check notification validation if (objHttp.status <> 200 ) then ' HTTP error handling elseif (objHttp.responseText = "VERIFIED") then ' assign posted variables to local variables invoice = Request.Form("invoice") st = UCASE(request.Form("payment_status")) tx = request.Form("txn_id") Set conn = Server.CreateObject("ADODB.Connection") conn.Open "shopusersdb" Set Connection = conn 'update database sqlQuery = "UPDATE transaction SET tx = '" & tx & "',st='" & st & "' WHERE invoice = " & invoice Set objSendmail = CreateObject("CDONTS.NewMail") With objSendmail .MailFormat = 0 .BodyFormat = 0 .From = "shop@cheekyideas.com" .to = "ian@cheekyideas.com" .Subject = "<---Payment Verified--->" .Body ="" & invoice & ":" & sqlQuery & ":" & request.querystring & ":" & request.form & "" '.Send End With set objSendmail = NOTHING conn.Execute(sqlQuery) if st = "COMPLETED" then 'email to customer sqlQuery = "SELECT * FROM transaction where invoice = " & invoice set rs = conn.Execute(sqlQuery) custOrder = rs("custOrder") custEmail = rs("custEmail") custFirstName = rs("custFirstName") custLastName = rs("custLastName") custAdd = rs("custAdd") custCountry = rs("custCountry") custPostal = rs("custPostal") custContactNo = rs("custContactNo") custEmail = rs("custEmail") orderDate = rs("orderDate") '## PREPARE EMAIL TO SEND OUT messageHead ="Date:" & orderDate & "

"&_ "= = = = = = = = = = = = =
"&_ " Your Order Summary
"&_ "= = = = = = = = = = = = =

"&_ "Dear " & custFirstName & ",

"&_ "Thank you for shopping at CheekyIdeas. We have received your order and it will take about 3 working days to process.

" messageBill = custOrder messageShippingDetails = " "&_ "= = = = = = = = = = = = =
"&_ " Shipping Details
"&_ "= = = = = = = = = = = = =

"&_ "All items that have not been customized or do not have a custom shipping address will be delivered to this address
" &_ "

Name: " & custFirstName & " " & custLastName & "
"&_ "Address: " & custAdd & "
"&_ "Country: " & custCountry & "
"&_ "Postal Code: " & custPostal & "
"&_ "Contact No: " & custContactNo & "
"&_ "Email: " & custEmail & "

" messageDisclaimer = "= = = = = = = = = = = = =
"&_ "Disclaimer
"&_ "= = = = = = = = = = = = =

"&_ "While we try to fulfill our customer's requests as soon as we are able to,
"&_ "there are occasions where delivery will be delayed due to stock replenishment. "&_ "As such we hope to seek your kind understanding should there be any delays in delivery.

"&_ "This is an automated reply. Please do not reply to this email.

"&_ "If you require any assistance, please email to shop@cheekyideas.com

"&_ "Thank you for shopping at CheekyIdeas." message = messageHead & messageBill & messageShippingDetails & messageDisclaimer '## EXECUTE SEND EMAIL NOTIFICATION Set objSendmail = CreateObject("CDONTS.NewMail") With objSendmail .MailFormat = 0 .BodyFormat = 0 .From = "shop@cheekyideas.com" .to = custEmail .bcc= "shop@cheekyideas.com,ian@cheekyideas.com" .Subject = "<---Order Confirmation-" & tx & "-" & custFirstName & " " & custLastName & "-->" .Body ="" &_ "TRANSACTION NO: " & tx & "
" &_ message & "" .Send End With set objSendmail = NOTHING end if elseif (objHttp.responseText = "INVALID") then ' log for manual investigation 'if POST from PayPal is INVALID, send email using CDO Set objSendmail = CreateObject("CDONTS.NewMail") With objSendmail .MailFormat = 0 .BodyFormat = 0 .From = "shop@cheekyideas.com" .to = custEmail .bcc= "shop@cheekyideas.com" .Subject = "<---Order Submission Error--->" .Body ="" & "Dear user, an error has occurred during the payment process. Please contact us if you are facing any payment issues." & "" .Send End With set objSendmail = NOTHING else ' error end if set objHttp = nothing %>