<%@ Language=VBScript %> <% ' dim variables Dim sResponse, sCustom, sItemName, sPaymentStatus, sReceiverEmail Dim sTransactionID, TransAlreadyExists Dim oXML, oTransaction Dim dPaymentGross ' define response back to PayPal server sResponse = Request.Form & "&cmd=_notify-validate" ' open new XML object and send response back Set oXML = Server.CreateObject("MSXML2.ServerXMLHTTP") oXML.Open "POST", "https://www.paypal.com/cgi-bin/webscr", False oXML.SetRequestHeader "Content-type", "application/x-www-form-urlencoded" oXML.Send sResponse ' get the important details from form post sCustom = Request.Form("custom") sItemName = Request.Form("item_name") sPaymentStatus = Request.Form("payment_status") dPaymentGross = CDbl(Request.Form("mc_gross")) ' needs to be converted to double sReceiverEmail = Request.Form("receiver_email") sTransactionID = Request.Form("txn_id") TransAlreadyExists = False 'Check that transaction Id hasn't come back before since PayPal is throwing double callbacks unnecessarily If Len(Application("ppTxnId"))=0 Then Application("ppTxnId")="," TransAlreadyExists = InStr(Application("ppTxnId"), ","& sTransactionID &",") > 0 If Not TransAlreadyExists Then Application("ppTxnId")=Application("ppTxnId") & sTransactionID &"," If oXML.Status <> 200 Then ' if there's an error on the PayPal server, do nothing ElseIf oXML.ResponseText = "VERIFIED" Then ' if the payment callback is verified If UCase(sPaymentStatus) = "COMPLETED" And IsValidGateway("PAYPAL_Enabled", "PAYPALCallBackIPs", sItemName) And TransAlreadyExists = False Then ' if the payment has been completed (as opposed to a refund!) ' and PayPal is a valid gateway, make the payment Set oTransaction = Server.CreateObject("HELM.CTransaction") oTransaction.MakePayment sCustom, sItemName, dPaymentGross Set oTransaction = Nothing End If ElseIf oXML.ResponseText = "INVALID" Then ' if the callback is invalid, do nothing Else ' some other error End If Set oXML = Nothing %>