public void btnSecureNetSaveCard_Click(object sender, EventArgs e)
        {
            Page.Validate("SecureNetAddCard");
            if (!Page.IsValid)
            {
                return;
            }
            SecureNetVault snv = new SecureNetVault(ThisCustomer);

            try
            {
                ServiceResponse response = snv.AddCreditCardToCustomerVault(SecureNetCreditCardPanel.CreditCardName, SecureNetCreditCardPanel.CreditCardNumber, SecureNetCreditCardPanel.CreditCardVerCd, SecureNetCreditCardPanel.CreditCardType, SecureNetCreditCardPanel.CardExpMonth, SecureNetCreditCardPanel.CardExpYr);
                if (!response.HasError)
                {
                    LoadData();
                    pnlAddSecureNetCard.Visible       = false;
                    pnlAddSecureNetCardPrompt.Visible = true;
                    SecureNetCreditCardPanel.Clear();
                }
                else
                {
                    litSNCError.Text = response.Message + "<br />";
                }
            }
            catch
            {
                litSNCError.Text = "There was an error adding your credit card. Please validate the provided information and try again.<br />";
            }
        }
        protected void dlSecureNetVault_DeleteCommand(object sender, DataListCommandEventArgs e)
        {
            HiddenField hfVaultId = e.Item.FindControl("hfVaultId") as HiddenField;

            if (hfVaultId != null && !string.IsNullOrEmpty(hfVaultId.Value))
            {
                SecureNetVault vault = new SecureNetVault(ThisCustomer);
                try
                {
                    vault.DeletePaymentMethod(hfVaultId.Value);
                }
                catch { }
            }
            LoadData();
        }
Пример #3
0
        public String ProcessCard(int OrderNumber, int CustomerID, Decimal OrderTotal, bool useLiveTransactions, TransactionModeEnum TransactionMode, Address UseBillingAddress, String CardExtraCode, Address UseShippingAddress, String CAVV, String ECI, String XID, out String AVSResult, out String AuthorizationResult, out String AuthorizationCode, out String AuthorizationTransID, out String TransactionCommandOut, out String TransactionResponse, Boolean IsVaultTransaction, Customer ThisCustomer)
        {
            if (IsVaultTransaction && ThisCustomer == null)
            {
                throw new ArgumentException("Customer Object required for vault transactions.");
            }

            String result = AppLogic.ro_OK;

            AuthorizationCode     = String.Empty;
            AuthorizationResult   = String.Empty;
            AuthorizationTransID  = String.Empty;
            AVSResult             = String.Empty;
            TransactionCommandOut = String.Empty;
            TransactionResponse   = String.Empty;

            GatewayClient client = SecureNetController.GetGatewayClient();

            TRANSACTION oT = SecureNetController.GetTransactionWithDefaults();

            if (IsVaultTransaction)
            {
                //vault info
                oT.CUSTOMERID = ThisCustomer.CustomerID.ToString();
                oT.PAYMENTID  = AppLogic.GetSelectedSecureNetVault(ThisCustomer);
            }
            else
            {
                //Credit Card Info
                oT.CARD            = new CARD();
                oT.CARD.CARDCODE   = CardExtraCode;
                oT.CARD.CARDNUMBER = UseBillingAddress.CardNumber;
                oT.CARD.EXPDATE    = UseBillingAddress.CardExpirationMonth.PadLeft(2, '0') + UseBillingAddress.CardExpirationYear.ToString().Substring(2, 2); //MMYY
            }


            //Billing Address Info
            oT.CUSTOMER_BILL           = new CUSTOMER_BILL();
            oT.CUSTOMER_BILL.ADDRESS   = UseBillingAddress.Address1;
            oT.CUSTOMER_BILL.CITY      = UseBillingAddress.City;
            oT.CUSTOMER_BILL.ZIP       = UseBillingAddress.Zip;
            oT.CUSTOMER_BILL.STATE     = UseBillingAddress.State;
            oT.CUSTOMER_BILL.COMPANY   = UseBillingAddress.Company;
            oT.CUSTOMER_BILL.COUNTRY   = UseBillingAddress.Country;
            oT.CUSTOMER_BILL.EMAIL     = UseBillingAddress.EMail;
            oT.CUSTOMER_BILL.FIRSTNAME = UseBillingAddress.FirstName;
            oT.CUSTOMER_BILL.LASTNAME  = UseBillingAddress.LastName;
            oT.CUSTOMER_BILL.PHONE     = UseBillingAddress.Phone;

            //Shipping Address Info
            if (UseShippingAddress != null)
            {
                oT.CUSTOMER_SHIP           = new CUSTOMER_SHIP();
                oT.CUSTOMER_SHIP.ADDRESS   = UseShippingAddress.Address1;
                oT.CUSTOMER_SHIP.CITY      = UseShippingAddress.City;
                oT.CUSTOMER_SHIP.ZIP       = UseShippingAddress.Zip;
                oT.CUSTOMER_SHIP.STATE     = UseShippingAddress.State;
                oT.CUSTOMER_SHIP.COMPANY   = UseShippingAddress.Company;
                oT.CUSTOMER_SHIP.COUNTRY   = UseShippingAddress.Country;
                oT.CUSTOMER_SHIP.FIRSTNAME = UseShippingAddress.FirstName;
                oT.CUSTOMER_SHIP.LASTNAME  = UseShippingAddress.LastName;
            }

            //todo - look into adding cartitems

            //Transaction Information
            oT.AMOUNT      = OrderTotal;
            oT.CODE        = CommonLogic.IIF(AppLogic.TransactionModeIsAuthOnly(), SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.AUTH_ONLY), SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.AUTH_CAPTURE));
            oT.METHOD      = SecureNetMethod.CC.ToString();
            oT.ORDERID     = OrderNumber.ToString();
            oT.CUSTOMERIP  = CommonLogic.CustomerIpAddress();
            oT.INVOICENUM  = OrderNumber.ToString();
            oT.INVOICEDESC = AppLogic.AppConfig("StoreName");

            //pasing unused integers as zeros as defined in the securenet docs
            oT.TOTAL_INSTALLMENTCOUNT  = 0;
            oT.OVERRIDE_FROM           = 0;
            oT.INSTALLMENT_SEQUENCENUM = 0;
            oT.RETAIL_LANENUM          = 0;
            oT.CASHBACK_AMOUNT         = 0;

            if (IsVaultTransaction)
            {
                oT.TRANSACTION_SERVICE = 1;
            }
            else
            {
                oT.TRANSACTION_SERVICE = 0;
            }

            //MPI for 3D Secure
            oT.MPI = new MPI();

            if (!String.IsNullOrEmpty(ECI))
            {
                oT.MPI.AUTHINDICATOR = ECI;
            }

            if (!String.IsNullOrEmpty(CAVV))
            {
                oT.MPI.AUTHVALUE = CAVV;
            }

            GATEWAYRESPONSE oG = client.ProcessTransaction(oT);

            if (oG.TRANSACTIONRESPONSE.RESPONSE_CODE == "1")
            {
                AuthorizationTransID = oG.TRANSACTIONRESPONSE.TRANSACTIONID.ToString();
                AuthorizationCode    = "Response Code: " + oG.TRANSACTIONRESPONSE.RESPONSE_CODE + ", Reason Code: " + oG.TRANSACTIONRESPONSE.RESPONSE_REASON_CODE;

                if (!String.IsNullOrEmpty(oG.TRANSACTIONRESPONSE.AVS_RESULT_CODE))
                {
                    AVSResult = oG.TRANSACTIONRESPONSE.AVS_RESULT_CODE;
                }

                if (!String.IsNullOrEmpty(oG.TRANSACTIONRESPONSE.CARD_CODE_RESPONSE_CODE))
                {
                    if (AVSResult.Length > 0)
                    {
                        AVSResult += ", ";
                    }
                    AVSResult += "ExtraCode: " + oG.TRANSACTIONRESPONSE.CARD_CODE_RESPONSE_CODE;
                }

                //if (!String.IsNullOrEmpty(oTr.CAVV_Response_Code))
                if (!String.IsNullOrEmpty(oG.TRANSACTIONRESPONSE.CAVV_RESPONSE_CODE))
                {
                    if (AVSResult.Length > 0)
                    {
                        AVSResult += ", ";
                    }
                    AVSResult += "CAVV: " + oG.TRANSACTIONRESPONSE.CAVV_RESPONSE_CODE;
                }

                AuthorizationResult = oG.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT + ", Approval Code: " + oG.TRANSACTIONRESPONSE.AUTHCODE;
                result = AppLogic.ro_OK;
            }
            else
            {
                AuthorizationResult = "Error: [" + oG.TRANSACTIONRESPONSE.RESPONSE_CODE + "] " + oG.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
                result = oG.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
            }

            TransactionCommandOut = this.GetXMLSerializedObject(oT);
            TransactionResponse   = this.GetXMLSerializedObject(oG);

            if (!IsVaultTransaction && AppLogic.SecureNetVaultIsEnabled() && result == AppLogic.ro_OK)
            {
                if (ThisCustomer == null)
                {
                    ThisCustomer = new Customer(CustomerID);
                }
                if (ThisCustomer.SecureNetVaultMasterShouldWeStoreCreditCardInfo)
                {
                    try
                    {
                        SecureNetVault vault = new SecureNetVault(ThisCustomer);
                        vault.AddCreditCardToCustomerVault(UseBillingAddress.CardName, UseBillingAddress.CardNumber, CardExtraCode, UseBillingAddress.CardType, UseBillingAddress.CardExpirationMonth, UseBillingAddress.CardExpirationYear);
                    }
                    catch { }
                }
            }

            if (IsVaultTransaction && result == AppLogic.ro_OK)
            {
                AppLogic.ClearSelectedSecureNetVaultInSession(ThisCustomer);
            }

            return(result);
        }
Пример #4
0
        private void ProcessCheckout()
        {
            Address BillingAddress = new Address();

            BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);

            int OrderNumber = 0;
            // ----------------------------------------------------------------
            // Process The Order:
            // ----------------------------------------------------------------
            ErrorMessage err;

            if (PaymentMethod.Length == 0 || PM != AppLogic.CleanPaymentMethod(BillingAddress.PaymentMethodLastUsed))
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.20", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("checkoutpayment.aspx?errormsg=" + err.MessageId);
            }
            if (PM == AppLogic.ro_PMCreditCard)
            {
                if (Cardinal.EnabledForCheckout(cart.Total(true), BillingAddress.CardType))
                {
                    OrderNumber = AppLogic.GetNextOrderNumber();

                    if (Cardinal.PreChargeLookupAndStoreSession(ThisCustomer, OrderNumber, cart.Total(true),
                                                                BillingAddress.CardNumber, BillingAddress.CardExpirationMonth, BillingAddress.CardExpirationYear))
                    {
                        Response.Redirect("cardinalform.aspx");                        // this will eventually come "back" to us in cardinal_process.aspx after going through banking system pages
                    }
                    else
                    {
                        // user not enrolled or cardinal gateway returned error, so process card normally, using already created order #:

                        string ECIFlag = Cardinal.GetECIFlag(BillingAddress.CardType);

                        String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, ECIFlag, String.Empty, String.Empty);
                        if (status != AppLogic.ro_OK)
                        {
                            err = new ErrorMessage(Server.HtmlEncode(status));
                            Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                        }
                        DB.ExecuteSQL("update orders set CardinalLookupResult=" + DB.SQuote(ThisCustomer.ThisCustomerSession["Cardinal.LookupResult"]) + " where OrderNumber=" + OrderNumber.ToString());
                    }
                }
                else
                {
                    decimal CartTotal = cart.Total(true);
                    decimal NetTotal  = CartTotal - CommonLogic.IIF(cart.Coupon.CouponType == CouponTypeEnum.GiftCard, CommonLogic.IIF(CartTotal < cart.Coupon.DiscountAmount, CartTotal, cart.Coupon.DiscountAmount), 0);
                    // this is  specific for nexaxept gateway
                    if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWNETAXEPT &&
                        NetTotal > System.Decimal.Zero)
                    {
                        int  ordnum;
                        bool result = int.TryParse(ThisCustomer.ThisCustomerSession["Nextaxept_OrderNumber"], out ordnum);

                        if (result)
                        {
                            OrderNumber = ordnum;
                        }
                    }
                    else
                    {
                        // try create the order record, check for status of TX though:
                        OrderNumber = AppLogic.GetNextOrderNumber();
                    }
                    String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                    if (status == AppLogic.ro_3DSecure)
                    { // If credit card is enrolled in a 3D Secure service (Verified by Visa, etc.)
                        Response.Redirect("secureform.aspx");
                    }
                    if (status != AppLogic.ro_OK)
                    {
                        err = new ErrorMessage(Server.HtmlEncode(status));
                        Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                    }
                }
            }
            else if (PM == AppLogic.ro_PMPurchaseOrder)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCODMoneyOrder)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCODCompanyCheck)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCODNet30)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMPayPal)
            {
            }
            else if (PM == AppLogic.ro_PMPayPalExpress || PM == AppLogic.ro_PMPayPalExpressMark)
            {
                String PayPalToken = Security.UnmungeString(ThisCustomer.ThisCustomerSession["PayPalExpressToken"]);
                String PayerID     = Security.UnmungeString(ThisCustomer.ThisCustomerSession["PayPalExpressPayerID"]);
                if (PayPalToken.Length > 0)
                {
                    OrderNumber = AppLogic.GetNextOrderNumber();

                    Address UseBillingAddress = new Address();
                    UseBillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                    UseBillingAddress.PaymentMethodLastUsed = PM;
                    UseBillingAddress.CardNumber            = String.Empty;
                    UseBillingAddress.CardType            = String.Empty;
                    UseBillingAddress.CardExpirationMonth = String.Empty;
                    UseBillingAddress.CardExpirationYear  = String.Empty;
                    UseBillingAddress.CardName            = String.Empty;
                    UseBillingAddress.CardStartDate       = String.Empty;
                    UseBillingAddress.CardIssueNumber     = String.Empty;
                    UseBillingAddress.UpdateDB();

                    String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, PayPalToken, PayerID, String.Empty, String.Empty);
                    if (status != AppLogic.ro_OK)
                    {
                        err = new ErrorMessage(Server.HtmlEncode(status));
                        Response.Redirect("checkoutpayment.aspx?errormsg=" + err.MessageId);
                    }
                    else
                    {
                        ThisCustomer.ThisCustomerSession["PayPalExpressToken"]   = "";
                        ThisCustomer.ThisCustomerSession["PayPalExpressPayerID"] = "";
                    }
                }
                else
                {
                    err = new ErrorMessage("The PaypalExpress checkout token has expired, please re-login to your PayPal account or checkout using a different method of payment.");
                    Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMRequestQuote)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCheckByMail)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCOD)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMECheck)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMMicropay)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMSecureNetVault)
            {
                OrderNumber = AppLogic.GetNextOrderNumber();
                SecureNetVault vault  = new SecureNetVault(ThisCustomer);
                String         status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                //String status = vault.ProcessVaultTransaction();
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            Response.Redirect("orderconfirmation.aspx?ordernumber=" + OrderNumber.ToString() + "&paymentmethod=" + Server.UrlEncode(PaymentMethod));
        }
        private void ProcessCheckout()
        {
            Address BillingAddress = new Address();

            BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);

            int OrderNumber = 0;
            // ----------------------------------------------------------------
            // Process The Order:
            // ----------------------------------------------------------------
            ErrorMessage err;

            if (PaymentMethod.Length == 0 || PM != AppLogic.CleanPaymentMethod(BillingAddress.PaymentMethodLastUsed))
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.20", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("checkoutpayment.aspx?errormsg=" + err.MessageId);
            }
            if (PM == AppLogic.ro_PMCreditCard)
            {
                bool CardinalAllowed = AppLogic.ProductIsMLExpress() == false &&
                                       AppLogic.AppConfigBool("CardinalCommerce.Centinel.Enabled") && !(cart.Total(true) == System.Decimal.Zero && AppLogic.AppConfigBool("SkipPaymentEntryOnZeroDollarCheckout"));
                if (CardinalAllowed && (BillingAddress.CardType.Trim().Equals("VISA", StringComparison.InvariantCultureIgnoreCase) ||
                                        BillingAddress.CardType.Trim().Equals("MASTERCARD", StringComparison.InvariantCultureIgnoreCase) ||
                                        BillingAddress.CardType.Trim().Equals("JCB", StringComparison.InvariantCultureIgnoreCase)))
                {
                    // use cardinal pre-auth fraud screening:
                    String ACSUrl               = String.Empty;
                    String Payload              = String.Empty;
                    String TransactionID        = String.Empty;
                    String CardinalLookupResult = String.Empty;
                    OrderNumber = AppLogic.GetNextOrderNumber();
                    if (Cardinal.PreChargeLookup(BillingAddress.CardNumber, Localization.ParseUSInt(BillingAddress.CardExpirationYear), Localization.ParseUSInt(BillingAddress.CardExpirationMonth), OrderNumber, cart.Total(true), "", out ACSUrl, out Payload, out TransactionID, out CardinalLookupResult))
                    {
                        // redirect to intermediary page which gets card password from user:
                        ThisCustomer.ThisCustomerSession["Cardinal.LookupResult"]  = CardinalLookupResult;
                        ThisCustomer.ThisCustomerSession["Cardinal.ACSUrl"]        = ACSUrl;
                        ThisCustomer.ThisCustomerSession["Cardinal.Payload"]       = Payload;
                        ThisCustomer.ThisCustomerSession["Cardinal.TransactionID"] = TransactionID;
                        ThisCustomer.ThisCustomerSession["Cardinal.OrderNumber"]   = OrderNumber.ToString();

                        if (AppLogic.ProductIsMLExpress() == false)
                        {
                            Response.Redirect("cardinalform.aspx"); // this will eventually come "back" to us in cardinal_process.aspx after going through banking system pages
                        }
                    }
                    else
                    {
                        ThisCustomer.ThisCustomerSession["Cardinal.LookupResult"] = CardinalLookupResult;
                        // user not enrolled or cardinal gateway returned error, so process card normally, using already created order #:

                        // set the ECIFlag for an 'N' Enrollment response, so the merchant receives Liability Shift Protection
                        string ECIFlag;
                        if (BillingAddress.CardType.Trim().Equals("VISA", StringComparison.InvariantCultureIgnoreCase))
                        {
                            ECIFlag = "06";  // Visa Card Issuer Liability
                        }
                        else if (BillingAddress.CardType.Trim().Equals("JCB", StringComparison.InvariantCultureIgnoreCase))
                        {
                            ECIFlag = "07";  // Indicates Merchant Liability
                        }
                        else
                        {
                            ECIFlag = "01";  // MasterCard Merchant Liability for non-enrolled card (rules differ between MC and Visa in the regard)
                        }

                        String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, ECIFlag, String.Empty, String.Empty);
                        if (status != AppLogic.ro_OK)
                        {
                            err = new ErrorMessage(Server.HtmlEncode(status));
                            Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                        }
                        DB.ExecuteSQL("update orders set CardinalLookupResult=" + DB.SQuote(ThisCustomer.ThisCustomerSession["Cardinal.LookupResult"]) + " where OrderNumber=" + OrderNumber.ToString());
                    }
                }
                else
                {
                    decimal CartTotal = cart.Total(true);
                    decimal NetTotal  = CartTotal - CommonLogic.IIF(cart.Coupon.CouponType == CouponTypeEnum.GiftCard, CommonLogic.IIF(CartTotal < cart.Coupon.DiscountAmount, CartTotal, cart.Coupon.DiscountAmount), 0);
                    // this is  specific for nexaxept gateway
                    if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWNETAXEPT &&
                        NetTotal > System.Decimal.Zero)
                    {
                        int  ordnum;
                        bool result = int.TryParse(ThisCustomer.ThisCustomerSession["Nextaxept_OrderNumber"], out ordnum);

                        if (result)
                        {
                            OrderNumber = ordnum;
                        }
                    }
                    else
                    {
                        // try create the order record, check for status of TX though:
                        OrderNumber = AppLogic.GetNextOrderNumber();
                    }
                    String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                    if (status == AppLogic.ro_3DSecure)
                    { // If credit card is enrolled in a 3D Secure service (Verified by Visa, etc.)
                        Response.Redirect("secureform.aspx");
                    }
                    if (status != AppLogic.ro_OK)
                    {
                        err = new ErrorMessage(Server.HtmlEncode(status));
                        Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                    }
                }
            }
            else if (PM.ToLower() == GatewayCheckoutByAmazon.CheckoutByAmazon.CBA_Gateway_Identifier.ToLower())
            {
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("shoppingcart.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMPurchaseOrder)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCODMoneyOrder)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCODCompanyCheck)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCODNet30)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMPayPal)
            {
            }
            else if (PM == AppLogic.ro_PMPayPalExpress || PM == AppLogic.ro_PMPayPalExpressMark)
            {
                String PayPalToken = Security.UnmungeString(ThisCustomer.ThisCustomerSession["PayPalExpressToken"]);
                String PayerID     = Security.UnmungeString(ThisCustomer.ThisCustomerSession["PayPalExpressPayerID"]);
                if (PayPalToken.Length > 0)
                {
                    OrderNumber = AppLogic.GetNextOrderNumber();

                    Address UseBillingAddress = new Address();
                    UseBillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                    UseBillingAddress.PaymentMethodLastUsed = PM;
                    UseBillingAddress.CardNumber            = String.Empty;
                    UseBillingAddress.CardType            = String.Empty;
                    UseBillingAddress.CardExpirationMonth = String.Empty;
                    UseBillingAddress.CardExpirationYear  = String.Empty;
                    UseBillingAddress.CardName            = String.Empty;
                    UseBillingAddress.CardStartDate       = String.Empty;
                    UseBillingAddress.CardIssueNumber     = String.Empty;
                    UseBillingAddress.UpdateDB();

                    String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, PayPalToken, PayerID, String.Empty, String.Empty);
                    if (status != AppLogic.ro_OK)
                    {
                        err = new ErrorMessage(Server.HtmlEncode(status));
                        Response.Redirect("checkoutpayment.aspx?errormsg=" + err.MessageId);
                    }
                    else
                    {
                        ThisCustomer.ThisCustomerSession["PayPalExpressToken"]   = "";
                        ThisCustomer.ThisCustomerSession["PayPalExpressPayerID"] = "";
                    }
                }
                else
                {
                    err = new ErrorMessage("The PaypalExpress checkout token has expired, please re-login to your PayPal account or checkout using a different method of payment.");
                    Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMRequestQuote)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCheckByMail)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMCOD)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMECheck)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMMicropay)
            {
                // try create the order record, check for status of TX though:
                OrderNumber = AppLogic.GetNextOrderNumber();
                String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            else if (PM == AppLogic.ro_PMSecureNetVault)
            {
                OrderNumber = AppLogic.GetNextOrderNumber();
                SecureNetVault vault  = new SecureNetVault(ThisCustomer);
                String         status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);
                //String status = vault.ProcessVaultTransaction();
                if (status != AppLogic.ro_OK)
                {
                    err = new ErrorMessage(Server.HtmlEncode(status));
                    Response.Redirect("checkoutpayment.aspx?TryToShowPM=" + PM + "&errormsg=" + err.MessageId);
                }
            }
            Response.Redirect("orderconfirmation.aspx?ordernumber=" + OrderNumber.ToString() + "&paymentmethod=" + Server.UrlEncode(PaymentMethod));
        }