<%@LANGUAGE="VBScript"%> <% //=============================================================================== // AlertPay Instant Payment Notification (IPN) //=============================================================================== // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. //=============================================================================== // Script: AlertURL.asp // Platform: ASP // Language: VBScript // Purpose: // -------- // The purpose of this code is to help you to understand how to process the Instant Payment Notification // variables for Subscription Button and integrate it in your ASP site. // How to Use: // ----------- // Put this code into the page which you have specified as Alert URL. // The variables being read from the Request object in the below code are pre-defined IPN variables and the // the conditional blocks provide you the logical placeholders to process the IPN variables. It is your responsibility // to write appropriate code as per your requirements. // Developer Feedback: // -------------- // If you have any questions about this script or any suggestions, please email to: devsupport@alertpay.com. ' Security code variable Dim ap_SecurityCode ' Customer info variables Dim ap_CustFirstName, ap_CustLastName, ap_CustAddress, ap_CustCity Dim ap_CustCountry, ap_CustZip, ap_CustEmailAddress 'Common transaction variables Dim ap_ReferenceNumber, ap_Status, ap_PurchaseType, ap_Merchant Dim ap_ItemName, ap_ItemCode, ap_Description, ap_Quantity, ap_Amount, ap_AdditionalCharges Dim ap_ShippingCharges, ap_TaxAmount, ap_DiscountAmount, ap_TotalAmount, ap_Currency Dim ap_Test ' Custom fields Dim ap_Apc_1, ap_Apc_2, ap_Apc_3, ap_Apc_4, ap_Apc_5, ap_Apc_6 ' Subscription variables Dim ap_SubscriptionReferenceNumber, ap_TimeUnit, ap_PeriodLength, ap_PeriodCount, ap_NextRunDate Dim ap_TrialTimeUnit, ap_TrialPeriodLength, ap_TrialAmount 'Initialize varibale setSecurityCodeVariable() If ap_SecurityCode <> "W2cTGHv8v6ELEflpBndaQg" Then ' The Data is NOT sent by AlertPay. ' Take appropriate action Else If ap_Test = "1" Then ' Your site is currently being integrated with AlertPay IPN for TESTING PURPOSES ' ONLY. Don't store any information in your Production database and don't process ' this transaction as a real order. Else ' Initialize variables setCustomerInfoVariables() setCommonTransactionVariables() ' Initialize the custom field variables. setCustomFields() ' If the transaction is subscription-based (recurring payment), initialize the ' Subscription variables too. If ap_PurchaseType = "Subscription" Then setSubscriptionVariables() If ap_ReferenceNumber.Length = 0 And ap_TrialAmount <> "0" Then ' Invalid reference number. The reference number is invalid because the ap_ReferenceNumber doesn't ' contain a value and the ap_TrialAmount is not equal to 0. Else If ap_Status = "Success" Then ' Transaction is complete. It means that the amount was paid successfully. ' Process the order here. ' Process non-subscription order. If ap_PurchaseType <> "Subscription" Then ' NOTE: The subscription variables are not applicable here. Don't use them. ' Process the subscription order. Use ap_SubscriptionReferenceNumber to uniquely identify ' this particular subscription transaction. Else ' Check whether the trial is free or not If ap_TrialAmount = "0" Then ' Process the free trial here. ' NOTE: The ap_ReferenceNumber is always empty for trial periods and therefore you ' should not use it. Else ' The is not a free trial and ap_TrialAmount contains some amount and the ' ap_ReferenceNumber contains a valid transaction reference number. End If End If Else ' Transaction cancelled means seller explicitely cancelled the subscription or AlertPay ' cancelled or it was cancelled since buyer didnt have enough money after resheduling after two times. ' Take Action appropriately End If End If End If End If End If Sub setSecurityCodeVariable() ap_SecurityCode = Request.Form("ap_securitycode") End Sub Sub setCustomerInfoVariables() ap_CustFirstName = Request.Form("ap_custfirstname") ap_CustLastName = Request.Form("ap_custlastname") ap_CustAddress = Request.Form("ap_custaddress") ap_CustCity = Request.Form("ap_custcity") ap_CustCountry = Request.Form("ap_custcountry") ap_CustZip = Request.Form("ap_custzip") ap_CustEmailAddress = Request.Form("ap_custemailaddress") ap_PurchaseType = Request.Form("ap_purchasetype") ap_Merchant = Request.Form("ap_merchant") End Sub Sub setCommonTransactionVariables() ap_ItemName = Request.Form("ap_itemname") ap_Description = Request.Form("ap_description") ap_Quantity = Request.Form("ap_quantity") ap_Amount = Request.Form("ap_amount") ap_AdditionalCharges=Request.Form("ap_additionalcharges") ap_ShippingCharges=Request.Form("ap_shippingcharges") ap_TaxAmount=Request.Form("ap_taxamount") ap_DiscountAmount=Request.Form("ap_discountamount") ap_TotalAmount = Request.Form("ap_totalamount") ap_Currency = Request.Form("ap_currency") ap_ReferenceNumber = Request.Form("ap_referencenumber") ap_Status = Request.Form("ap_status") ap_ItemCode = Request.Form("ap_itemcode") ap_Test = Request.Form("ap_test") End Sub Sub setSubscriptionVariables() ap_SubscriptionReferenceNumber = Request.Form("ap_subscriptionreferencenumber") ap_TimeUnit=Request.Form("ap_timeunit") ap_PeriodLength=Request.Form("ap_periodlength") ap_PeriodCount=Request.Form("ap_periodcount") ap_NextRunDate=Request.Form("ap_nextrundate") ap_TrialTimeUnit=Request.Form("ap_trialtimeunit") ap_TrialPeriodLength=Request.Form("ap_trialperiodlength") ap_TrialAmount=Request.Form("ap_trialamount") End Sub Sub setCustomFields() ap_Apc_1 = Request.Form("apc_1") ap_Apc_2 = Request.Form("apc_2") ap_Apc_3 = Request.Form("apc_3") ap_Apc_4 = Request.Form("apc_4") ap_Apc_5 = Request.Form("apc_5") ap_Apc_6 = Request.Form("apc_6") End Sub %>