Exemplo n.º 1
0
        protected override void OnInit(EventArgs e)
        {
            cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

            ShippingMethodCollection shippingMethods = cart.GetShippingMethods(ThisCustomer.PrimaryShippingAddress);

            if (shippingMethods.Count > 0)
            {
                AnyShippingMethodsFound = true;
            }

            InitializeShippingMethodDisplayFormat(shippingMethods);
            ctrlShippingMethods.DataSource = shippingMethods;
            ctrlShippingMethods.DataBind();

            ctrlShoppingCart.DataSource = cart.CartItems;
            ctrlShoppingCart.DataBind();

            ctrlCartSummary.DataSource = cart;
            ctrlCartSummary.DataBind();

            InitializeOrderOptionControl();

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut)
            {
                pnlCBAAddressWidget.Visible         = true;
                litCBAAddressWidget.Text            = new GatewayCheckoutByAmazon.CheckoutByAmazon().RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", "checkoutshipping.aspx", new Guid(ThisCustomer.CustomerGUID), 300, 200);
                litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();
            }

            base.OnInit(e);
        }
Exemplo n.º 2
0
        private void LoadData()
        {
            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            var addresses = new Addresses();

            foreach (Address address in GetAddresses())
            {
                if (checkoutByAmazon.IsAmazonAddress(address))
                {
                    continue;
                }

                address.AddressType = this.AddressMode;

                if (CheckPOBox(address.Address1) && (address.AddressType == AddressTypes.Shipping) && (AppLogic.AppConfigBool("DisallowShippingToPOBoxes")))
                {
                    lblPOBoxError.Visible = true;
                    lblPOBoxError.Text    = "address.cs.80".StringResource();
                }
                else
                {
                    addresses.Add(address);  //show addresses that have no po boxes.
                }
            }

            dlAddress.DataSource = addresses;
            dlAddress.DataBind();
        }
Exemplo n.º 3
0
        private void ShippingDisplay(bool AnyShippingMethodsFound)
        {
            if (cart.CartAllowsShippingMethodSelection)
            {
                ctrlShippingMethods.HeaderText = string.Empty;

                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (Shipping.MultiShipEnabled() && cart.TotalQuantity() > 1 && cart.TotalQuantity() <= AppLogic.MultiShipMaxNumItemsAllowed() && !checkoutByAmazon.IsCheckingOut)
                {
                    lblMultiShipPrompt.Visible = true;
                    lblMultiShipPrompt.Text    = "<p><b>" + String.Format(AppLogic.GetString("checkoutshipping.aspx.15", SkinID, ThisCustomer.LocaleSetting), "checkoutshippingmult.aspx") + "</b></p>";
                }
                else
                {
                    lblMultiShipPrompt.Visible = false;
                }

                Boolean CustomerLevelHasFreeShipping = false;
                if (ThisCustomer.CustomerLevelID > 0)
                {
                    using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                    {
                        con.Open();
                        using (IDataReader clvl = DB.GetRS("SELECT LevelHasFreeShipping FROM CustomerLevel WHERE CustomerLevelID=" + ThisCustomer.CustomerLevelID.ToString(), con))
                        {
                            while (clvl.Read())
                            {
                                CustomerLevelHasFreeShipping = DB.RSFieldBool(clvl, "LevelHasFreeShipping");
                            }
                        }
                    }
                }

                //If cart is all items that do not require shipping direct to checkoutpayment
                if (cart.NoShippingRequiredComponents())
                {
                    if (cart.ContainsGiftCard())
                    {
                        Response.Redirect("checkoutgiftcard.aspx");
                    }
                    else
                    {
                        Response.Redirect("checkoutpayment.aspx");
                    }
                }

                if (!AppLogic.AppConfigBool("FreeShippingAllowsRateSelection") && (cart.IsAllFreeShippingComponents() || (!AnyShippingMethodsFound && cart.ShippingIsFree) || CustomerLevelHasFreeShipping || cart.FreeShippingReason == Shipping.FreeShippingReasonEnum.ExceedsFreeShippingThreshold || cart.FreeShippingReason == Shipping.FreeShippingReasonEnum.CouponHasFreeShipping))
                {
                    ErrorMsgLabel.Text         += "<p><b>" + cart.GetFreeShippingReason() + "</b></p>";
                    ctrlShippingMethods.Visible = false;
                    pnlErrorMsg.Visible         = true;
                }
                else
                {
                    ctrlShippingMethods.HeaderText += "<p><b>" + AppLogic.GetString("checkoutshipping.aspx.11", SkinID, ThisCustomer.LocaleSetting) + "</b></p>";
                    btnContinueCheckout.Text        = AppLogic.GetString("checkoutshipping.aspx.13", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.Clear();
            Response.BufferOutput = true;

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            checkoutByAmazon.HandleCallback();

            Response.StatusCode = 200;
            Response.Flush();
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            SkinBase.RequireSecurePage();

            int OrderNumber     = CommonLogic.QueryStringUSInt("OrderNumber");
            int OrderCustomerID = Order.GetOrderCustomerID(OrderNumber);

            Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;// who is logged in now viewing this page:

            // currently viewing user must be logged in to view receipts:
            if (!ThisCustomer.IsRegistered)
            {
                Response.Redirect("signin.aspx?returnurl=receipt.aspx?" + Server.UrlEncode(CommonLogic.ServerVariables("QUERY_STRING")));
            }

            // are we allowed to view?
            // if currently logged in user is not the one who owns the order, and this is not an admin user who is logged in, reject the view:
            if (ThisCustomer.CustomerID != OrderCustomerID && !ThisCustomer.IsAdminUser)
            {
                Response.Redirect(SE.MakeDriverLink("ordernotfound"));
            }

            //For multi store checking
            //Determine if customer is allowed to view orders from other store.
            if (!ThisCustomer.IsAdminUser && AppLogic.StoreID() != AppLogic.GetOrdersStoreID(OrderNumber) && AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true)
            {
                Response.Redirect(SE.MakeDriverLink("ordernotfound"));
            }

            Order o = new Order(OrderNumber, ThisCustomer.LocaleSetting);

            if (o.PaymentMethod != null && o.PaymentMethod.ToLower() == GatewayCheckoutByAmazon.CheckoutByAmazon.CBA_Gateway_Identifier.ToLower())
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                Response.Write(checkoutByAmazon.RenderOrderDetailWidget(o.OrderNumber));
            }
            else
            {
                Response.Write(o.Receipt(ThisCustomer, false));
            }
        }
        protected void PaymentMethodModel_ActivePaymentMethodChanged(object source, EventArgs args)
        {
            // refresh the account model
            this.AccountModel.LoadContext(HttpContext.Current.User.Identity.Name);

            this.PaymentModel.AccountModel      = this.AccountModel;
            this.ShoppingCartModel.AccountModel = this.AccountModel;

            if (!(PaymentModel.ActivePaymentMethod is Vortx.OnePageCheckout.Models.PaymentMethods.Adnsf9200.CheckOutByAmazonPayment))
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                checkoutByAmazon.ResetCheckout(AspDotNetStorefrontCore.Customer.Current.CustomerID);
                //Response.Redirect("smartcheckout.aspx");
            }
            else
            {
                PanelCheckOutByAmazonShipping.Visible = true;
                LitAmazonPaymentWidget.Visible        = true;
            }
            // Refresh page state
            this.ShowCurrentPageState();
        }
Exemplo n.º 7
0
        public void RefreshPage()
        {
            Address BillingAddress  = new Address();
            Address ShippingAddress = new Address();

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

            if (Checkout)
            {
                pnlCheckoutImage.Visible = true;
                CheckoutImage.ImageUrl   = AppLogic.SkinImage("step_2.gif");
                if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress() || (AppLogic.AppConfigBool("DisallowShippingToPOBoxes") && CheckPOBox(ShippingAddress.Address1)))
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);;
                }
            }

            String XRI = AppLogic.SkinImage("redarrow.gif");

            redarrow1.ImageUrl       = XRI;
            redarrow2.ImageUrl       = XRI;
            redarrow3.ImageUrl       = XRI;
            pnlCheckoutImage.Visible = Checkout;
            ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));

            ErrorMsgLabel.Text       += Server.HtmlEncode(e.Message);
            pnlAccountUpdated.Visible = AccountUpdated;
            if (AccountUpdated)
            {
                if (!NewEmailAddressAllowed)
                {
                    lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting);
                }
            }

            pnlNotCheckOutButtons.Visible      = !Checkout;
            pnlShowWishButton.Visible          = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("ShowWishButtons");
            pnlShowGiftRegistryButtons.Visible = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("ShowGiftRegistryButtons");
            pnlSubscriptionExpiresOn.Visible   = (ThisCustomer.SubscriptionExpiresOn > System.DateTime.Now);
            lblSubscriptionExpiresOn.Text      = String.Format(AppLogic.GetString("account.aspx.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn));
            OriginalEMail.Text      = ThisCustomer.EMail;
            imgAccountinfo.ImageUrl = AppLogic.SkinImage("accountinfo.gif");
            note1.Visible           = (ThisCustomer.CustomerLevelID != 0);
            note1.Text = String.Format(AppLogic.GetString("account.aspx.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CustomerLevelName);
            MicroPayEnabled.Visible       = (AppLogic.MicropayIsEnabled() && ThisCustomer.IsRegistered && AppLogic.GetMicroPayProductID() != 0);
            MicroPayEnabled.Text          = String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance));
            btnContinueToCheckOut.Visible = Checkout;

            lnkChangeBilling.ImageUrl  = AppLogic.SkinImage("change.gif");
            lnkChangeShipping.ImageUrl = AppLogic.SkinImage("change.gif");
            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (ThisCustomer.PrimaryBillingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryBillingAddress))
            {
                pnlBilling.Visible = false;
            }
            if (ThisCustomer.PrimaryShippingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryShippingAddress))
            {
                pnlShipping.Visible = false;
            }
            lnkChangeBilling.NavigateUrl  = "javascript:self.location='address.aspx?Checkout=" + Checkout.ToString() + "&AddressType=billing&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            lnkChangeShipping.NavigateUrl = "javascript:self.location='address.aspx?Checkout=" + Checkout.ToString() + "&AddressType=shipping&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            imgAddressbook.ImageUrl       = AppLogic.SkinImage("addressbook.gif");

            lnkAddBillingAddress.NavigateUrl  = "address.aspx?add=true&addressType=Billing&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            lnkAddBillingAddress.Text         = AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting);
            lnkAddShippingAddress.NavigateUrl = "address.aspx?add=true&addressType=Shipping&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            lnkAddShippingAddress.Text        = AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting);

            litBillingAddress.Text = BillingAddress.DisplayHTML(Checkout);
            if (BillingAddress.PaymentMethodLastUsed.Length != 0)
            {
                litBillingAddress.Text += "<b>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting) + "</b><br/>";
                litBillingAddress.Text += BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed);
            }

            if (CheckPOBox(ShippingAddress.Address1))
            {
                litShippingAddress.Text = "<span style=\"color:red; font-weight:bold;\">" + "createaccount_process.aspx.3".StringResource() + "</span>"; //PO box not allowed
            }
            else
            {
                litShippingAddress.Text = ShippingAddress.DisplayHTML(Checkout);
            }

            pnlOrderHistory.Visible  = !Checkout;
            imgOrderhistory.ImageUrl = AppLogic.SkinImage("orderhistory.gif");


            if (!AppLogic.m_ProductIsML())
            {
                // gift cards not supported in PRO
            }
            else
            {
                GiftCards gc = new GiftCards(ThisCustomer.CustomerID, GiftCardCollectionFilterType.UsingCustomerID);
                if (gc.Count > 0)
                {
                    rptrGiftCards.DataSource = gc;
                    rptrGiftCards.DataBind();
                    tblGiftCards.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor"));
                    tblGiftCardsBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle"));
                    giftcards_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/giftcards.gif");
                    pnlGiftCards.Visible   = true;
                }
            }
            if (ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0)
            {
                RecurringOrders.Text = "<p align=\"left\"><b>" + AppLogic.GetString("account.aspx.35", SkinID, ThisCustomer.LocaleSetting) + "</b></p>";

                // build JS code to show/hide address update block:
                StringBuilder tmpS = new StringBuilder(4096);
                tmpS.Append("<script type=\"text/javascript\">\n");
                tmpS.Append("function toggleLayer(DivID)\n");
                tmpS.Append("{\n");
                tmpS.Append("	var elem;\n");
                tmpS.Append("	var vis;\n");
                tmpS.Append("	if(document.getElementById)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// standards\n");
                tmpS.Append("		elem = document.getElementById(DivID);\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.all)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// old msie versions\n");
                tmpS.Append("		elem = document.all[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.layers)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// nn4\n");
                tmpS.Append("		elem = document.layers[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis = elem.style;\n");
                tmpS.Append("	if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n");
                tmpS.Append("}\n");
                tmpS.Append("</script>\n");
                tmpS.Append("\n");
                tmpS.Append("<style type=\"text/css\">\n");
                tmpS.Append("	.addressBlockDiv { margin: 0px 20px 0px 20px;  display: none;}\n");
                tmpS.Append("</style>\n");
                RecurringOrders.Text += tmpS.ToString();

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", con))
                    {
                        while (rsr.Read())
                        {
                            RecurringOrders.Text += AppLogic.GetRecurringCart(base.EntityHelpers, base.GetParser, ThisCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false);
                        }
                    }
                }

                RecurringOrders.Text += "<br/><br/>";
            }

            string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) };

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " +
                                                               "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes  from dbo.orders   with (NOLOCK)  where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates),
                                                               ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con))
                {
                    orderhistorylist.DataSource = rs;
                    orderhistorylist.DataBind();
                }
            }

            accountaspx55.Visible = (orderhistorylist.Items.Count == 0);

            ctrlAccount.Password        = String.Empty;
            ctrlAccount.PasswordConfirm = String.Empty;

            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true);
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("UseStringPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.stringPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            Checkout     = CommonLogic.QueryStringBool("checkout");
            if (Checkout)
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (checkoutByAmazon.IsCheckingOut)
                {
                    pnlCBAAddressWidget.Visible         = true;
                    litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200);
                    litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();

                    tblAccount.Visible = false;
                }

                ThisCustomer.RequireCustomerRecord();
            }

            ErrorMsgLabel.Text    = "";
            lblAcctUpdateMsg.Text = "";

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                ErrorMsgLabel.Text = "<b><center>" + AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting) + "</center></b>";
            }

            ThisCustomer.ValidatePrimaryAddresses();

            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = pnlShipping2.Visible = false;
            }

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.CancelRecurringOrder(DeleteID);
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillFullRefund(FullRefundID);
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillPartialRefund(PartialRefundID);
            }

            //SkinImagePath = "~/App_Themes/skin_" + SkinID.ToString() + "/images/";

            if (!this.IsPostBack)
            {
                ctrlAccount.FirstName         = ThisCustomer.FirstName;
                ctrlAccount.LastName          = ThisCustomer.LastName;
                ctrlAccount.Email             = ThisCustomer.EMail.ToLowerInvariant().Trim();
                ctrlAccount.Password          = String.Empty;
                ctrlAccount.PasswordConfirm   = String.Empty;
                ctrlAccount.Phone             = ThisCustomer.Phone;
                ctrlAccount.SaveCC            = ThisCustomer.MasterShouldWeStoreCreditCardInfo || ThisCustomer.SecureNetVaultMasterShouldWeStoreCreditCardInfo;
                ctrlAccount.Over13            = ThisCustomer.IsOver13;
                ctrlAccount.VATRegistrationID = ThisCustomer.VATRegistrationID;
                if (ThisCustomer.OKToEMail)
                {
                    ctrlAccount.OKToEmailYes = true;
                }
                else
                {
                    ctrlAccount.OKToEmailNo = true;
                }

                RefreshPage();
            }
        }
Exemplo n.º 9
0
        private void CreateAccount()
        {
            ThisCustomer.RequireCustomerRecord();
            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && checkoutByAmazon.GetDefaultShippingAddress() == null)
            {
                lblErrorMessage.Text = "gw.checkoutbyamazon.display.3".StringResource();
                pnlErrorMsg.Visible  = true;
                return;
            }

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && ThisCustomer.IsRegistered)
            {
                checkoutByAmazon.BeginCheckout(new Guid(ThisCustomer.CustomerGUID), false, false);
                Response.Redirect("checkoutshipping.aspx");
            }
            else if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut)
            {
                checkoutByAmazon.BeginCheckout(new Guid(ThisCustomer.CustomerGUID), false, false);
            }

            SetPasswordFields();

            string AccountName = (ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim()).Trim();

            if (SkipRegistration)
            {
                AccountName = String.Format("{0} {1}", ctrlBillingAddress.FirstName.Trim(), ctrlBillingAddress.LastName.Trim()).Trim();

                if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut)
                {
                    AccountName = "Anonymous Amazon Customer";
                }
            }

            if (SkipRegistration)
            {
                Page.Validate("skipreg");
            }
            else
            {
                if (ctrlAccount.Password.Contains('\xFF') || ctrlAccount.Password.Length == 0)
                {
                    ctrlAccount.PasswordValidate = ViewState["custpwd"].ToString();
                }
                else
                {
                    ctrlAccount.PasswordValidate = ctrlAccount.Password;
                }

                if (ctrlAccount.PasswordConfirm.Contains('\xFF') || ctrlAccount.PasswordConfirm.Length == 0)
                {
                    ctrlAccount.PasswordConfirmValidate = ViewState["custpwd2"].ToString();
                }
                else
                {
                    ctrlAccount.PasswordConfirmValidate = ctrlAccount.PasswordConfirm;
                }

                ctrlAccount.Over13 = ctrlAccount.Over13;
                if ((!ThisCustomer.IsRegistered) && !checkoutByAmazon.IsCheckingOut && (ctrlAccount.Password.Length == 0 || ctrlAccount.PasswordConfirm.Length == 0))
                {
                    lblErrorMessage.Text = "createaccount.aspx.6".StringResource();
                    ResetScrollPosition();
                    pnlErrorMsg.Visible = true;
                    return;
                }

                ctrlBillingAddress.CountryIDToValidateZipCode  = AppLogic.GetCountryID(ctrlBillingAddress.Country);
                ctrlShippingAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlShippingAddress.Country);

                Page.Validate("registration");

                if (RequireSecurityCode)
                {
                    if (Session["SecurityCode"] != null)
                    {
                        String  sCode     = Session["SecurityCode"].ToString();
                        String  fCode     = ctrlAccount.txtSecurityCode.Text;
                        Boolean codeMatch = false;

                        if (AppLogic.AppConfigBool("Captcha.CaseSensitive"))
                        {
                            if (fCode.Equals(sCode))
                            {
                                codeMatch = true;
                            }
                        }
                        else
                        {
                            if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase))
                            {
                                codeMatch = true;
                            }
                        }

                        if (!codeMatch)
                        {
                            lblErrorMessage.Text                         = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), sCode, fCode);
                            ctrlAccount.txtSecurityCode.Text             = String.Empty;
                            ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1";
                            ResetScrollPosition();
                            pnlErrorMsg.Visible = true;
                            return;
                        }
                    }
                    else
                    {
                        lblErrorMessage.Text                         = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), "", ctrlAccount.txtSecurityCode.Text);
                        ctrlAccount.txtSecurityCode.Text             = String.Empty;
                        ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1";
                        ResetScrollPosition();
                        pnlErrorMsg.Visible = true;
                        return;
                    }
                }

                if (!Page.IsValid && RequireSecurityCode)
                {
                    Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6);
                }
            }



            Page.Validate("createacccount");


            if (Page.IsValid && AccountName.Length > 0)
            {
                String EMailField = CommonLogic.IIF(SkipRegistration, txtSkipRegEmail.Text.ToLowerInvariant().Trim(), ctrlAccount.Email.ToLowerInvariant().Trim());

                bool NewEmailAllowed = Customer.NewEmailPassesDuplicationRules(EMailField, ThisCustomer.CustomerID, SkipRegistration);

                String   PWD    = ViewState["custpwd"].ToString();
                Password p      = new Password(PWD);
                String   newpwd = p.SaltedPassword;
                System.Nullable <int> newsaltkey = p.Salt;

                Password blankpwd = new Password("", ThisCustomer.SaltKey);
                if (!(ThisCustomer.Password == "" || ThisCustomer.Password == blankpwd.SaltedPassword))
                {
                    // do NOT allow passwords to be changed on this page. this is only for creating an account.
                    // if they want to change their password, they must use their account page
                    newpwd     = null;
                    newsaltkey = null;
                }
                if (NewEmailAllowed)
                {
                    AppLogic.eventHandler("CreateAccount").CallEvent("&CreateAccount=true");

                    string strDOB = null;
                    if (AppLogic.AppConfigBool("Account.ShowBirthDateField"))
                    {
                        strDOB = ctrlAccount.DOBMonth + "/" + ctrlAccount.DOBDay + "/" + ctrlAccount.DOBYear;
                        //DOB defaults to 0/0/0 when doing anonymous checkout and blows up dbo.aspdnsf_updCustomer, preventing checkout
                        strDOB = (strDOB.Equals("0/0/0", StringComparison.Ordinal)) ? null : strDOB;
                    }

                    var defaultCustomerLevel_Public = (int)UserType.PUBLIC;

                    ThisCustomer.UpdateCustomer(
                        /*CustomerLevelID*/ defaultCustomerLevel_Public,
                        /*EMail*/ EMailField,
                        /*SaltedAndHashedPassword*/ newpwd,
                        /*SaltKey*/ newsaltkey,
                        /*DateOfBirth*/ strDOB,
                        /*Gender*/ null,
                        /*FirstName*/ ctrlAccount.FirstName,
                        /*LastName*/ ctrlAccount.LastName,
                        /*Notes*/ null,
                        /*SkinID*/ null,
                        /*Phone*/ ctrlAccount.Phone,
                        /*AffiliateID*/ null,
                        /*Referrer*/ null,
                        /*CouponCode*/ null,
                        /*OkToEmail*/ CommonLogic.IIF(ctrlAccount.OKToEmailYes, 1, 0),
                        /*IsAdmin*/ null,
                        /*BillingEqualsShipping*/ CommonLogic.IIF(AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"), 0, 1),
                        /*LastIPAddress*/ null,
                        /*OrderNotes*/ null,
                        /*SubscriptionExpiresOn*/ null,
                        /*RTShipRequest*/ null,
                        /*RTShipResponse*/ null,
                        /*OrderOptions*/ null,
                        /*LocaleSetting*/ null,
                        /*MicroPayBalance*/ null,
                        /*RecurringShippingMethodID*/ null,
                        /*RecurringShippingMethod*/ null,
                        /*BillingAddressID*/ null,
                        /*ShippingAddressID*/ null,
                        /*GiftRegistryGUID*/ null,
                        /*GiftRegistryIsAnonymous*/ null,
                        /*GiftRegistryAllowSearchByOthers*/ null,
                        /*GiftRegistryNickName*/ null,
                        /*GiftRegistryHideShippingAddresses*/ null,
                        /*CODCompanyCheckAllowed*/ null,
                        /*CODNet30Allowed*/ null,
                        /*ExtensionData*/ null,
                        /*FinalizationData*/ null,
                        /*Deleted*/ null,
                        /*Over13Checked*/ 1, //CommonLogic.IIF(ctrlAccount.Over13 || SkipRegOver13.Checked, 1, 0),
                        /*CurrencySetting*/ null,
                        /*VATSetting*/ null,
                        /*VATRegistrationID*/ null,
                        /*StoreCCInDB*/ CommonLogic.IIF(ctrlAccount.ShowSaveCC, ctrlAccount.SaveCC, true),
                        /*IsRegistered*/ CommonLogic.IIF(SkipRegistration, 0, 1),
                        /*LockedUntil*/ null,
                        /*AdminCanViewCC*/ null,
                        /*BadLogin*/ null,
                        /*Active*/ null,
                        /*PwdChangeRequired*/ null,
                        /*RegisterDate*/ null,
                        /*StoreId*/ AppLogic.StoreID()
                        );
                    if (ctrlAccount.OKToEmailYes)
                    {
                        AddToNewsletterList(ctrlAccount.FirstName, ctrlAccount.LastName, EMailField);
                    }
                    BillingAddress = ThisCustomer.PrimaryBillingAddress;
                    if (BillingAddress.AddressID == 0 && !checkoutByAmazon.IsCheckingOut)
                    {
                        if (pnlBillingInfo.Visible)
                        {
                            BillingAddress.NickName      = ctrlBillingAddress.NickName;
                            BillingAddress.LastName      = ctrlBillingAddress.LastName;
                            BillingAddress.FirstName     = ctrlBillingAddress.FirstName;
                            BillingAddress.Phone         = ctrlBillingAddress.PhoneNumber;
                            BillingAddress.Company       = ctrlBillingAddress.Company;
                            BillingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlBillingAddress.ResidenceType);
                            BillingAddress.Address1      = ctrlBillingAddress.Address1;
                            BillingAddress.Address2      = ctrlBillingAddress.Address2;
                            BillingAddress.Suite         = ctrlBillingAddress.Suite;
                            BillingAddress.City          = ctrlBillingAddress.City;
                            BillingAddress.State         = ctrlBillingAddress.State;
                            BillingAddress.Zip           = ctrlBillingAddress.ZipCode;
                            BillingAddress.Country       = ctrlBillingAddress.Country;

                            BillingAddress.InsertDB(ThisCustomer.CustomerID);
                            BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Billing);
                        }
                    }
                    else
                    {
                        BillingAddress.NickName  = String.Format("{0} {1}", ctrlAccount.FirstName, ctrlAccount.LastName);
                        BillingAddress.LastName  = ctrlAccount.FirstName;
                        BillingAddress.FirstName = ctrlAccount.LastName;
                        BillingAddress.Phone     = ctrlAccount.Phone;
                    }

                    ShippingAddress = ThisCustomer.PrimaryShippingAddress;
                    if (ShippingAddress.AddressID == 0 && !checkoutByAmazon.IsCheckingOut)
                    {
                        if (AllowShipToDifferentThanBillTo)
                        {
                            if (ctrlShippingAddress.Visible)
                            {
                                ShippingAddress.NickName      = ctrlBillingAddress.NickName;
                                ShippingAddress.LastName      = ctrlShippingAddress.LastName;
                                ShippingAddress.FirstName     = ctrlShippingAddress.FirstName;
                                ShippingAddress.Phone         = ctrlShippingAddress.PhoneNumber;
                                ShippingAddress.Company       = ctrlShippingAddress.Company;
                                ShippingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlShippingAddress.ResidenceType);
                                ShippingAddress.Address1      = ctrlShippingAddress.Address1;
                                ShippingAddress.Address2      = ctrlShippingAddress.Address2;
                                ShippingAddress.Suite         = ctrlShippingAddress.Suite;
                                ShippingAddress.City          = ctrlShippingAddress.City;
                                ShippingAddress.State         = ctrlShippingAddress.State;
                                ShippingAddress.Zip           = ctrlShippingAddress.ZipCode;
                                ShippingAddress.Country       = ctrlShippingAddress.Country;

                                ShippingAddress.InsertDB(ThisCustomer.CustomerID);
                                if (!String.IsNullOrEmpty(VerifyAddressesProvider))
                                {
                                    VerifyResult        = AddressValidation.RunValidate(ShippingAddress, out StandardizedAddress);
                                    VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);
                                    if (VerifyAddressPrompt)
                                    {
                                        ShippingAddress = StandardizedAddress;
                                        ShippingAddress.UpdateDB();
                                    }
                                }
                                ShippingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping);
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(VerifyAddressesProvider))
                            {
                                VerifyResult        = AddressValidation.RunValidate(BillingAddress, out StandardizedAddress);
                                VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);
                                if (VerifyAddressPrompt)
                                {
                                    BillingAddress = StandardizedAddress;
                                    BillingAddress.UpdateDB();
                                }
                            }
                            BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping);
                        }
                    }
                    else
                    {
                        ShippingAddress.NickName  = String.Format("{0} {1}", ctrlAccount.FirstName, ctrlAccount.LastName);
                        ShippingAddress.LastName  = ctrlAccount.FirstName;
                        ShippingAddress.FirstName = ctrlAccount.LastName;
                        ShippingAddress.Phone     = ctrlAccount.Phone;
                    }

                    if (AppLogic.AppConfigBool("Vat.Enabled") && ctrlAccount.VATRegistrationID.Length > 0)
                    {
                        String vtr = ctrlAccount.VATRegistrationID.Trim();

                        Exception vatServiceException = null;
                        if (AppLogic.VATRegistrationIDIsValid(ctrlBillingAddress.Country, vtr, out vatServiceException))
                        {
                            ThisCustomer.SetVATRegistrationID(vtr);
                        }
                        else
                        {
                            vtr = String.Empty;

                            if (vatServiceException != null && !String.IsNullOrEmpty(vatServiceException.Message))
                            {
                                if (vatServiceException.Message.Length > 255)
                                {
                                    lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message.Substring(0, 255));
                                }
                                else
                                {
                                    lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message);
                                }
                            }
                            else
                            {
                                lblErrorMessage.Text = "account.aspx.91".StringResource();
                            }
                            pnlErrorMsg.Visible = true;
                            return;
                        }
                    }
                    if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") ||
                        AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled"))
                    {
                        ThisCustomer.ReplaceProductViewFromAnonymous();
                    }
                }
                if (Checkout)
                {
                    if (!NewEmailAllowed)
                    {
                        lblErrorMessage.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale());
                        InitializePageContent();
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1 && ThisCustomer.IsRegistered == true)
                        {
                            // don't let a simple welcome stop checkout!
                            try
                            {
                                string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"),
                                                                     null,
                                                                     ThisCustomer,
                                                                     this.SkinID,
                                                                     "",
                                                                     "fullname=" + ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(),
                                                                     false,
                                                                     false,
                                                                     this.EntityHelpers);

                                AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting),
                                                  body,
                                                  true,
                                                  AppLogic.AppConfig("MailMe_FromAddress"),
                                                  AppLogic.AppConfig("MailMe_FromName"),
                                                  EMailField,
                                                  ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(),
                                                  "",
                                                  AppLogic.MailServer());
                            }
                            catch { }
                        }
                        if (VerifyAddressPrompt)
                        {
                            if (AllowShipToDifferentThanBillTo)
                            {
                                Response.Redirect("address.aspx?Checkout=True&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration + "&returnURL=checkoutshipping.aspx?checkout=true");
                            }
                            else
                            {
                                Response.Redirect("address.aspx?Checkout=True&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration + "&returnURL=checkoutshipping.aspx?checkout=true");
                            }
                        }
                        else
                        {
                            if (checkouttype == "ppec" || checkouttype == "ppbml" || checkouttype == "gc")
                            {
                                Response.Redirect("shoppingcart.aspx");
                            }
                            else
                            {
                                Response.Redirect("account.aspx?checkout=true");//checkoutshipping
                            }
                        }
                    }
                }
                else
                {
                    if (!NewEmailAllowed)
                    {
                        DB.ExecuteSQL("update customer set EMail='', IsRegistered = 0 where CustomerID=" + ThisCustomer.CustomerID);
                        lblErrorMessage.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale());
                        InitializePageContent();
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1 && ThisCustomer.IsRegistered == true)
                        {
                            // don't let a simple welcome stop checkout!
                            try
                            {
                                string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"),
                                                                     null,
                                                                     ThisCustomer,
                                                                     this.SkinID,
                                                                     "",
                                                                     "",
                                                                     false,
                                                                     false,
                                                                     this.EntityHelpers);

                                AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting),
                                                  body,
                                                  true,
                                                  AppLogic.AppConfig("MailMe_FromAddress"),
                                                  AppLogic.AppConfig("MailMe_FromName"),
                                                  EMailField,
                                                  ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), "",
                                                  AppLogic.MailServer());
                            }
                            catch { }
                        }
                        if (VerifyAddressPrompt)
                        {
                            if (AllowShipToDifferentThanBillTo)
                            {
                                Response.Redirect("address.aspx?Checkout=False&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration);
                            }
                            else
                            {
                                Response.Redirect("address.aspx?Checkout=False&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration);
                            }
                        }
                        else
                        {
                            Response.Redirect("JWMyAccount.aspx");
                        }
                    }
                }
            }
            else
            {
                foreach (IValidator aValidator in this.Validators)
                {
                    if (!aValidator.IsValid)
                    {
                        lblErrorMessage.Text = aValidator.ErrorMessage;
                        break;
                    }
                }
                ResetScrollPosition();
            }

            pnlErrorMsg.Visible = lblErrorMessage.Text.Length > 0;
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = -1;
            Response.AddHeader("pragma", "no-cache");

            ErrorMessage err;

            if (AppLogic.AppConfigBool("RequireOver13Checked") && !ThisCustomer.IsOver13)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkout.over13required", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
            }

            bool phoneCustomer = ((HttpContext.Current.Items["IsBeingImpersonated"] != null) &&
                                  ((string)HttpContext.Current.Items["IsBeingImpersonated"] == "true"));

            bool paypalExpressCheckout = (ThisCustomer.ThisCustomerSession["paypalexpresspayerid"].ToString().Length == 0 &&
                                          ThisCustomer.ThisCustomerSession["paypalexpresstoken"].ToString().Length == 0);

            var checkoutController = CheckOutPageControllerFactory.CreateCheckOutPageController(ThisCustomer, cart);

            if (checkoutController.GetCheckoutType() == CheckOutType.SmartOPC)
            {
                if (!phoneCustomer && checkoutController.CanUseOnePageCheckout())
                {
                    Response.Redirect(checkoutController.GetSmartOnePageCheckoutPage());
                }
            }
            else if (checkoutController.GetCheckoutType() == CheckOutType.BasicOPC)
            {
                if (!paypalExpressCheckout && checkoutController.CanUseOnePageCheckout())
                {
                    Response.Redirect(checkoutController.GetBasicOnePageCheckoutPage());
                }
            }

            RequireSecurePage();

            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------
            ThisCustomer.RequireCustomerRecord();

            if (!ThisCustomer.IsRegistered)
            {
                bool boolAllowAnon = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout");
                if (!boolAllowAnon && ThisCustomer.PrimaryBillingAddressID > 0)
                {
                    Address BillingAddress = new Address();
                    BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                    if (BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpress || BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpressMark)
                    {
                        boolAllowAnon = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout");
                    }
                }

                if (!boolAllowAnon)
                {
                    Response.Redirect("createaccount.aspx?checkout=true");
                }
            }
            if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.2", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            SectionTitle = AppLogic.GetString("checkoutshipping.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            cart         = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

            cart.ValidProceedCheckout(); // will not come back from this if any issue. they are sent back to the cart page!

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            if (checkoutByAmazon.IsCheckingOut)
            {
                if (checkoutByAmazon.GetDefaultShippingAddress() == null)
                {
                    btnContinueCheckout.OnClientClick = "alert('" + "gw.checkoutbyamazon.display.3".StringResource() + "'); return false;";
                }
            }

            if (!cart.IsAllDownloadComponents() && !cart.IsAllFreeShippingComponents() && !cart.IsAllSystemComponents() && (cart.HasMultipleShippingAddresses() || cart.HasGiftRegistryComponents()) && cart.TotalQuantity() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection && cart.TotalQuantity() > 1 && !checkoutByAmazon.IsCheckingOut)
            {
                Response.Redirect("checkoutshippingmult.aspx");
            }

            //MOD GS - If entire cart is email gift cards...redirect to checkoutgiftcard.aspx
            if (cart.IsAllEmailGiftCards())
            {
                Response.Redirect("checkoutgiftcard.aspx");
            }

            if (AppLogic.AppConfigBool("SkipShippingOnCheckout") ||
                cart.IsAllSystemComponents() ||
                cart.IsAllDownloadComponents() ||
                cart.NoShippingRequiredComponents())
            {
                if (cart.ContainsGiftCard())
                {
                    Response.Redirect("checkoutgiftcard.aspx");
                }
                else
                {
                    if (ThisCustomer.ThisCustomerSession["PayPalExpressToken"] == "")
                    {
                        Response.Redirect("checkoutpayment.aspx");
                    }
                    else
                    {
                        Response.Redirect("checkoutreview.aspx?PaymentMethod=PAYPALEXPRESS");
                    }
                }
            }

            pnlSelectShipping.Visible = AppLogic.AppConfigBool("AllowAddressChangeOnCheckoutShipping") && AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !checkoutByAmazon.IsCheckingOut;

            ctrlShippingMethods.ErrorMessage = string.Empty;
            pnlErrorMsg.Visible = false;

            CartItem FirstCartItem            = (CartItem)cart.CartItems[0];
            Address  FirstItemShippingAddress = new Address();

            FirstItemShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, FirstCartItem.ShippingAddressID, AddressTypes.Shipping);
            if (FirstItemShippingAddress.AddressID == 0)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutshipping.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
            }

            if (!this.IsPostBack)
            {
                if (!AppLogic.AppConfigBool("AllowMultipleShippingAddressPerOrder") && CommonLogic.QueryStringCanBeDangerousContent("dontupdateid").Length == 0)
                {
                    // force primary shipping address id to be active on all cart items (safety check):
                    DB.ExecuteSQL("update ShoppingCart set ShippingAddressID=(select ShippingAddressID from customer where CustomerID=" + ThisCustomer.CustomerID.ToString() + ") where CustomerID=" + ThisCustomer.CustomerID.ToString() + " and CartType=" + ((int)CartTypeEnum.ShoppingCart).ToString());
                    Response.Redirect("checkoutshipping.aspx?dontupdateid=true");
                }
                InitializePageContent();
            }
            else
            {
                pnlErrorMsg.Visible = false;
                if (CommonLogic.FormCanBeDangerousContent("btnContinueCheckout") != "")
                {
                    ProcessCheckOut();
                }
            }

            ctrlShoppingCart.HeaderTabImageURL     = AppLogic.SkinImage("OrderInfo.gif");
            ctrlShoppingCart.HeaderTabEditOderLink = string.Format(" {0}<a href=\"ShoppingCart.aspx\"> {1}</a>", AppLogic.GetString("checkoutcard.aspx.9", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("checkoutcard.aspx.10", SkinID, ThisCustomer.LocaleSetting));

            AppLogic.eventHandler("CheckoutShipping").CallEvent("&CheckoutShipping=true");
        }
Exemplo n.º 11
0
 private void SetMultiShipVisibility()
 {
     GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
     PanelMultiShip.Visible = ConfigurationProvider.DefaultProvider.AllowMultipleShippingAddressPerOrder &&
                              (this.ShoppingCartModel.ShoppingCartItems.Count() > 1 || this.ShoppingCartModel.ShoppingCartItems.FirstOrDefault().Quantity > 1) && !(checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut);
 }
        private void InitializePageState()
        {
            this.LoginView.Show();
            this.LoginView.BindView();
            this.LoginView.Disable();

            if (this.ShoppingCartModel.ShippingRequired)
            {
                this.PanelShippingMethod.Visible      = true;
                this.PanelShippingAddressWrap.Visible = true;

                this.ShipMethodView.Show();
                this.ShipMethodView.BindView();
                this.ShipMethodView.Disable();
            }
            else
            {
                this.PanelShippingMethod.Visible      = false;
                this.PanelShippingAddressWrap.Visible = false;

                this.ShipMethodView.Hide();
            }

            this.PaymentView.Show();
            this.PaymentView.BindView();
            this.PaymentView.Disable();

            this.ShippingAddressStaticView.Hide();
            this.ShippingAddressEditView.Hide();
            this.ShippingAddressEditUKView.Hide();
            this.ShippingAddressNoZipEditView.Hide();

            PanelTerms.Visible = ConfigurationProvider.DefaultProvider.RequireTermsAndConditions;
            PanelTerms.Enabled = false;

            PanelCheckboxOver13.Enabled = false;

            if (this.AccountModel.IsRegistered)
            {
                this.CreateAccountView.Hide();
                this.PanelCreateAccount.Visible = false;
                this.PanelEmailOptIn.Visible    = false;

                if (this.ShoppingCartModel.ShippingRequired)
                {
                    this.AddressBookView.Show();
                    this.AddressBookView.BindView();
                    this.AddressBookView.Disable();

                    this.HyperLinkShippingAddressBook.Enabled = true;
                    this.HyperLinkShippingAddressBook.Visible = true;

                    this.ShippingAddressStaticView.Show();
                    this.ShippingAddressStaticView.BindView();
                    this.ShippingAddressStaticView.Disable();
                }
            }
            else
            {
                this.EmailOptInYes.Enabled = this.AccountModel.AllowEmailSelected;

                litEmailPrefYes.Text = this.StringResourceProvider.GetString("smartcheckout.aspx.4");
                litEmailPrefNo.Text  = this.StringResourceProvider.GetString("smartcheckout.aspx.5");

                this.EmailOptInNo.Enabled    = this.AccountModel.AllowEmailSelected;
                this.PanelEmailOptIn.Visible = ConfigurationProvider.DefaultProvider.ShowEmailPreferencesOnCheckout;

                if (this.ShoppingCartModel.ShippingRequired)
                {
                    if (string.IsNullOrEmpty(this.AccountModel.ShippingAddress.Country))
                    {
                        if (ConfigurationProvider.DefaultProvider.AddressLocale.Equals("UK"))
                        {
                            this.ShippingAddressEditUKView.Initialize();
                            this.ShippingAddressEditUKView.Show();
                            this.ShippingAddressEditUKView.BindView();
                            this.ShippingAddressEditUKView.Disable();
                        }
                        else
                        {
                            if (ConfigurationProvider.DefaultProvider.UseZipcodeService)
                            {
                                this.ShippingAddressEditView.Initialize();
                                this.ShippingAddressEditView.Show();
                                this.ShippingAddressEditView.BindView();
                                this.ShippingAddressEditView.Disable();
                            }
                            else
                            {
                                this.ShippingAddressNoZipEditView.Initialize();
                                this.ShippingAddressNoZipEditView.Show();
                                this.ShippingAddressNoZipEditView.BindView();
                                this.ShippingAddressNoZipEditView.Disable();
                            }
                        }
                    }
                    else
                    {
                        this.ShippingAddressStaticView.Show();
                        this.ShippingAddressStaticView.BindView();
                        this.ShippingAddressStaticView.Disable();
                    }
                }

                if (!ConfigurationProvider.DefaultProvider.ShowCreateAccount &&
                    ConfigurationProvider.DefaultProvider.PasswordIsOptionalDuringCheckout)
                {
                    this.CreateAccountView.Hide();
                    this.PanelCreateAccount.Visible = false;
                }
                else
                {
                    this.CreateAccountView.Show();
                    this.CreateAccountView.BindView();
                    this.CreateAccountView.Disable();
                    this.PanelCreateAccount.Visible = true;
                }

                this.HyperLinkShippingAddressBook.Enabled = false;
                this.HyperLinkShippingAddressBook.Visible = false;

                this.AddressBookView.Hide();

                PanelCheckboxOver13.Visible = ConfigurationProvider.DefaultProvider.RequireOver13Checked;
            }

            // Show / Hide payment screen if zero dollar order
            PanelPaymentAndBilling.Visible = this.ShoppingCartModel.Total > 0;

            this.MiniCartCartSummary.BindView();

            // if amazon payments, show widgets, and disable shipping address editor
            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            var amazonPaymentModel = this.PaymentModel.PaymentMethods.FirstOrDefault(pm => pm.Key == PaymentType.CheckoutByAmazon).Value;

            if (amazonPaymentModel != null)
            {
                var paymentMethod = (CheckOutByAmazonPaymentModel)amazonPaymentModel;
                LitCheckOutByAmazoneShipping.Text = paymentMethod.RenderAddressWidget(new Guid(AspDotNetStorefrontCore.Customer.Current.CustomerGUID));
                LitAmazonPaymentWidget.Text       = paymentMethod.RenderWalletWidget();
            }

            if (IsCheckOutByAmazon())
            {
                PanelCheckOutByAmazonShipping.Visible = true;
                PanelShippingAddressWrap.Visible      = false;
                ShippingAddressEditView.Hide();
                ShippingAddressEditUKView.Hide();
                ShippingAddressStaticView.Hide();
                this.ShippingAddressEditView.Visible = false;

                if (checkoutByAmazon.GetDefaultShippingAddress() == null)
                {
                    SubmitOrder.OnClientClick = "alert('" + this.StringResourceProvider.GetString("gw.checkoutbyamazon.display.3") + "'); return false;";
                }
            }

            this.SubmitOrder.Visible = false;
            this.SubmitOrder.Enabled = false;
        }
 protected void btnRefreshCBAAddress_Click(Object sender, EventArgs e)
 {
     GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
     checkoutByAmazon.BeginCheckout(new Guid(AspDotNetStorefrontCore.Customer.Current.CustomerGUID), false, false);
     this.ShowCurrentPageState();
 }
        private void InitializePageContent()
        {
            JSPopupRoutines.Text           = AppLogic.GetJSPopupRoutines();
            checkoutheadergraphic.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/step_5.gif");
            for (int i = 0; i < checkoutheadergraphic.HotSpots.Count; i++)
            {
                RectangleHotSpot rhs = (RectangleHotSpot)checkoutheadergraphic.HotSpots[i];
                if (rhs.NavigateUrl.IndexOf("shoppingcart") != -1)
                {
                    rhs.AlternateText = AppLogic.GetString("checkoutreview.aspx.2", SkinID, ThisCustomer.LocaleSetting);
                }
                if (rhs.NavigateUrl.IndexOf("account") != -1)
                {
                    rhs.AlternateText = AppLogic.GetString("checkoutreview.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                }
                if (rhs.NavigateUrl.IndexOf("checkoutshipping") != -1)
                {
                    rhs.AlternateText = AppLogic.GetString("checkoutreview.aspx.4", SkinID, ThisCustomer.LocaleSetting);
                }
                if (rhs.NavigateUrl.IndexOf("checkoutpayment") != -1)
                {
                    rhs.AlternateText = AppLogic.GetString("checkoutreview.aspx.5", SkinID, ThisCustomer.LocaleSetting);
                }
            }
            if (!AppLogic.AppConfigBool("SkipShippingOnCheckout"))
            {
                checkoutheadergraphic.HotSpots[2].HotSpotMode = HotSpotMode.Navigate;
                checkoutheadergraphic.HotSpots[2].NavigateUrl = CommonLogic.IIF(cart.HasMultipleShippingAddresses(), "checkoutshippingmult.aspx", "checkoutshipping.aspx");
            }

            String XmlPackageName = AppLogic.AppConfig("XmlPackage.CheckoutReviewPageHeader");

            if (XmlPackageName.Length != 0)
            {
                XmlPackage_CheckoutReviewPageHeader.Text = "<br/>" + AppLogic.RunXmlPackage(XmlPackageName, base.GetParser, ThisCustomer, SkinID, String.Empty, String.Empty, true, true);
            }

            Address BillingAddress = new Address();

            BillingAddress.LoadFromDB(ThisCustomer.PrimaryBillingAddressID);
            Address ShippingAddress = new Address();

            ShippingAddress.LoadFromDB(ThisCustomer.PrimaryShippingAddressID);

            litBillingAddress.Text = BillingAddress.DisplayString(true, true, "<br/>");

            litPaymentMethod.Text = GetPaymentMethod(BillingAddress);


            if (cart.HasMultipleShippingAddresses())
            {
                litShippingAddress.Text = "<br/>" + AppLogic.GetString("checkoutreview.aspx.25", SkinID, ThisCustomer.LocaleSetting);
            }
            else if (cart.HasGiftRegistryComponents() && cart.HasGiftRegistryAddresses())
            {
                litShippingAddress.Text = "<br/>" + AppLogic.GetString("checkoutreview.aspx.26", SkinID, ThisCustomer.LocaleSetting);
            }
            else if (AppLogic.AppConfigBool("SkipShippingOnCheckout") || cart.IsAllDownloadComponents() || cart.IsAllSystemComponents())
            {
                ordercs57.Visible = false;
            }
            else
            {
                litShippingAddress.Text = ShippingAddress.DisplayString(true, true, "<br/>");
            }

            CartSummary.Text = cart.DisplaySummary(true, true, true, true, false);

            String XmlPackageName2 = AppLogic.AppConfig("XmlPackage.CheckoutReviewPageFooter");

            if (XmlPackageName2.Length != 0)
            {
                XmlPackage_CheckoutReviewPageFooter.Text = "<br/>" + AppLogic.RunXmlPackage(XmlPackageName2, base.GetParser, ThisCustomer, SkinID, String.Empty, String.Empty, true, true);
            }

            AppLogic.GetButtonDisable(btnContinueCheckout1);
            AppLogic.GetButtonDisable(btnContinueCheckout2);
            btnContinueCheckout1.Attributes["onclick"] = string.Format("{0}{1}", btnContinueCheckout1.Attributes["onclick"], "document.getElementById(\"" + btnContinueCheckout2.ClientID + "\").disabled = true;");
            btnContinueCheckout2.Attributes["onclick"] = string.Format("{0}{1}", btnContinueCheckout2.Attributes["onclick"], "document.getElementById(\"" + btnContinueCheckout1.ClientID + "\").disabled = true;");

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut)
            {
                pnlAmazonAddressWidget.Visible    =
                    pnlAmazonWalletWidget.Visible = true;

                litBillingAddress.Visible                   =
                    litShippingAddress.Visible              =
                        litPaymentMethod.Visible            =
                            checkoutreviewaspx8.Visible     =
                                checkoutreviewaspx9.Visible =
                                    ordercs57.Visible       = false;
            }
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (ThisCustomer.IsAdminUser || AppLogic.AppConfigBool("UseStrongPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.strongPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            Checkout = CommonLogic.QueryStringBool("checkout");
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            ctrlAccount.Attributes.Add("Disabled", "");
            if (Checkout)
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (checkoutByAmazon.IsCheckingOut)
                {
                    pnlCBAAddressWidget.Visible         = true;
                    litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200);
                    litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();

                    pnlAddress.Visible = false;
                }

                ThisCustomer.RequireCustomerRecord();
                CheckoutSteps.Visible = true;
            }
            else
            {
                CheckoutSteps.Visible = false;
            }

            lblErrorMessage.Text  = String.Empty;
            pnlErrorMsg.Visible   = false;
            lblAcctUpdateMsg.Text = String.Empty;

            var status = new StringBuilder();

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                lblErrorMessage.Text = AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting);
                pnlErrorMsg.Visible  = true;
            }

            ThisCustomer.ValidatePrimaryAddresses();

            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = false;
            }

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                Order             originalOrder = new Order(DeleteID);
                RecurringOrderMgr rmgr          = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);

                ExpressAPIType expressApiType = PayPalController.GetAppropriateExpressType();

                if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress)
                {
                    status.Append(rmgr.CancelPPECRecurringOrder(DeleteID, false));
                }
                else
                {
                    status.Append(rmgr.CancelRecurringOrder(DeleteID));
                }
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                status.Append(rmgr.ProcessAutoBillFullRefund(FullRefundID));
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                status.Append(rmgr.ProcessAutoBillPartialRefund(PartialRefundID));
            }

            //do not display an error message saying OK
            lblErrorMessage.Text = status.ToString() != AppLogic.ro_OK ? status.ToString() : String.Empty;
            pnlErrorMsg.Visible  = lblErrorMessage.Text.Length > 0;

            if (!this.IsPostBack)
            {
                RefreshPage();
                SetAccountFields();
                if (ThisCustomer.IsRegistered)
                {
                    this.hdnCustomerLevel1.Text = ThisCustomer.CustomerLevelID.ToString();
                }
                else
                {
                    hdnCustomerLevel1.Text = "-1";
                }
            }
        }
Exemplo n.º 16
0
        public void RefreshPage()
        {
            Address BillingAddress  = new Address();
            Address ShippingAddress = new Address();

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

            if (Checkout)
            {
                if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 ||
                    !ThisCustomer.HasAtLeastOneAddress() || (AppLogic.AppConfigBool("DisallowShippingToPOBoxes") && (!(new POBoxAddressValidator()).IsValid(ShippingAddress))))
                {
                    lblErrorMessage.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                    pnlErrorMsg.Visible  = true;
                }
            }

            ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));

            lblErrorMessage.Text     += Server.HtmlEncode(e.Message);
            pnlAccountUpdated.Visible = AccountUpdated;
            if (AccountUpdated)
            {
                if (!NewEmailAddressAllowed)
                {
                    lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                    ctrlAccount.Email      = ThisCustomer.EMail;
                }
                else
                {
                    lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting);
                }

                //In case email address confirmation is on.
                TextBox txtReEnterEmail = (TextBox)ctrlAccount.FindControl("txtReEnterEmail");
                if (txtReEnterEmail != null)
                {
                    txtReEnterEmail.Text = String.Empty;
                }
            }

            pnlNotCheckOutButtons.Visible      = !Checkout;
            pnlShowWishButton.Visible          = AppLogic.AppConfigBool("ShowWishButtons");
            pnlShowGiftRegistryButtons.Visible = AppLogic.AppConfigBool("ShowGiftRegistryButtons");
            pnlSubscriptionExpiresOn.Visible   = (ThisCustomer.SubscriptionExpiresOn > System.DateTime.Now);
            lblSubscriptionExpiresOn.Text      = String.Format(AppLogic.GetString("account.aspx.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn));
            OriginalEMail.Text = ThisCustomer.EMail;
            //lblCustomerLevel.Visible = pnlCustomerLevel.Visible = (ThisCustomer.CustomerLevelID != 0);
            lblCustomerLevel.Visible      = pnlCustomerLevel.Visible = false;
            lblCustomerLevel.Text         = String.Format(AppLogic.GetString("account.aspx.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CustomerLevelName);
            lblMicroPayEnabled.Visible    = pnlMicroPayEnabled.Visible = (AppLogic.MicropayIsEnabled() && ThisCustomer.IsRegistered && AppLogic.GetMicroPayProductID() != 0);
            lblMicroPayEnabled.Text       = String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance));
            btnContinueToCheckOut.Visible = Checkout;

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (ThisCustomer.PrimaryBillingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryBillingAddress))
            {
                //  pnlBilling.Visible = false;
            }
            if (ThisCustomer.PrimaryShippingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryShippingAddress))
            {
                //pnlShipping.Visible = false;
            }
            lnkChangeBilling.NavigateUrl  = "javascript:self.location='JWMyAddresses.aspx?Checkout=" + Checkout.ToString() + "&AddressType=1&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            lnkChangeShipping.NavigateUrl = "javascript:self.location='JWMyAddresses.aspx?Checkout=" + Checkout.ToString() + "&AddressType=2&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";

            //lnkAddBillingAddress.NavigateUrl = "JWMyAddresses.aspx?add=true&addressType=1&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            //lnkAddBillingAddress.Text = "<div>" + AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting) + "</div>";
            //lnkAddShippingAddress.NavigateUrl = "JWMyAddresses.aspx?add=true&addressType=2&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            //lnkAddShippingAddress.Text = "<div>" + AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting) + "</div>";

            if (BillingAddress.AddressID != 0)
            {
                litBillingAddress.Text = BillingAddress.DisplayHTML(true);
            }
            if (BillingAddress.PaymentMethodLastUsed.Length != 0)
            {
                //need for future use
                //litBillingAddress.Text += "<div>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting);
                //  litBillingAddress.Text += "<div>" + BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed) + "</div>";
            }

            if (!(new POBoxAddressValidator()).IsValid(ShippingAddress))
            {
                litShippingAddress.Text = "<div class='error-wrap'>" + "createaccount_process.aspx.3".StringResource() + "</div>"; //PO box not allowed
            }
            else
            {
                if (ShippingAddress.AddressID != 0)
                {
                    litShippingAddress.Text = "Cannot ship to P.O boxes" + ShippingAddress.DisplayHTML(true);
                }
            }


            pnlOrderHistory.Visible = !Checkout;

            GiftCards gc = new GiftCards(ThisCustomer.CustomerID, GiftCardCollectionFilterType.UsingCustomerID);

            if (gc.Count > 0)
            {
                rptrGiftCards.DataSource = gc;
                rptrGiftCards.DataBind();
                pnlGiftCards.Visible = true;
            }

            if (ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0)
            {
                ltRecurringOrders.Text = "<div class=\"group-header account-header recurring-header\">" + AppLogic.GetString("account.aspx.35", SkinID, ThisCustomer.LocaleSetting) + "</div>";

                // build JS code to show/hide address update block:
                StringBuilder tmpS = new StringBuilder(4096);
                tmpS.Append("<script type=\"text/javascript\">\n");
                tmpS.Append("function toggleLayer(DivID)\n");
                tmpS.Append("{\n");
                tmpS.Append("	var elem;\n");
                tmpS.Append("	var vis;\n");
                tmpS.Append("	if(document.getElementById)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// standards\n");
                tmpS.Append("		elem = document.getElementById(DivID);\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.all)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// old msie versions\n");
                tmpS.Append("		elem = document.all[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.layers)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// nn4\n");
                tmpS.Append("		elem = document.layers[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis = elem.style;\n");
                tmpS.Append("	if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n");
                tmpS.Append("}\n");
                tmpS.Append("</script>\n");
                tmpS.Append("\n");
                tmpS.Append("<style type=\"text/css\">\n");
                tmpS.Append("	.addressBlockDiv { margin: 0px 20px 0px 20px;  display: none;}\n");
                tmpS.Append("</style>\n");
                ltRecurringOrders.Text += tmpS.ToString();

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", con))
                    {
                        while (rsr.Read())
                        {
                            ltRecurringOrders.Text += AppLogic.GetRecurringCart(base.EntityHelpers, base.GetParser, ThisCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false);
                        }
                    }
                }
            }

            string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) };

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " +
                                                               "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes  from dbo.orders   with (NOLOCK)  where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates),
                                                               ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con))
                {
                    orderhistorylist.DataSource = rs;
                    orderhistorylist.DataBind();
                }
            }

            accountaspx55.Visible = (orderhistorylist.Items.Count == 0);

            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true);

            ctrlAccount.Password        = String.Empty;
            ctrlAccount.PasswordConfirm = String.Empty;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IModelFactory modelFactory = Vortx.OnePageCheckout.ObjectFactory.CreateModelFactory();
            IConfigurationProviderFactory configurationFactory = Vortx.OnePageCheckout.ObjectFactory.CreateConfigurationFactory();

            ConfigurationProvider.DefaultProvider = configurationFactory.CreateConfigurationProvider();

            this.StringResourceProvider = modelFactory.CreateStringResourceProvider();

            this.AccountModel = modelFactory.CreateAccountModel();
            this.AccountModel.CreateAccountCompleted         += new CreateAccountHandler(AccountModel_CreateAccountCompleted);
            this.AccountModel.FindAccountCompleted           += new FindAccountHandler(AccountModel_FindAccountCompleted);
            this.AccountModel.LogOnCompleted                 += new LogOnHandler(AccountModel_LogOnCompleted);
            this.AccountModel.LogOutCompleted                += new LogOutHandler(AccountModel_LogOutCompleted);
            this.AccountModel.AccountChanged                 += new AccountChangedHandler(AccountModel_AccountChanged);
            this.AccountModel.BillingAddress.AddressChanged  += new AddressChangedEventHandler(BillingAddressEditModel_AddressChanged);
            this.AccountModel.ShippingAddress.AddressChanged += new AddressChangedEventHandler(ShippingAddressEditModel_AddressChanged);
            this.AccountModel.PasswordChanged                += new PasswordChangedHandler(AccountModel_PasswordChanged);

            this.LoginView.StringResourceProvider = this.StringResourceProvider;
            this.LoginView.SetModel(this.AccountModel);

            this.CreateAccountView.StringResourceProvider = this.StringResourceProvider;
            this.CreateAccountView.SetModel(this.AccountModel);
            this.CreateAccountView.AccountCreationActivated += (o, ea) => ApplyAccountCreation();

            // Create shopping cart models
            this.ShoppingCartModel = modelFactory.CreateShoppingCartModel();
            this.ShoppingCartModel.AccountModel         = this.AccountModel;
            this.ShoppingCartModel.ItemQuantityChanged += new ItemQuantityChangedHandler(ShoppingCartModel_ItemQuantityChanged);
            this.ShoppingCartModel.ItemRemoved         += new ItemRemovedHandler(ShoppingCartModel_ItemRemoved);
            this.ShoppingCartModel.ShipMethodChanged   += new ShipMethodChangedEventHandler(ShipMethodModel_ShipMethodChanged);

            // Create shopping cart views
            this.ShipMethodView.StringResourceProvider = this.StringResourceProvider;
            this.ShipMethodView.SetModel(this.ShoppingCartModel);

            this.MiniCartView.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartView.SetModel(this.ShoppingCartModel);

            this.MiniCartCartSummary.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartCartSummary.SetModel(this.ShoppingCartModel);

            this.AddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.AddressBookView.SetModel(this.AccountModel);
            this.AddressBookView.SetAddressType(AddressType.Shipping);

            this.ShippingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressEditUKView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditUKView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressNoZipEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressNoZipEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressStaticView.SetModel(this.AccountModel.ShippingAddress);
            this.ShippingAddressStaticView.AddressEdit += new AddressEditEventHandler(ShippingAddressStaticView_AddressEdit);

            // Create payment model
            this.PaymentModel = modelFactory.CreatePaymentModel();
            this.PaymentModel.ActivePaymentMethodChanged += new ActivePaymentMethodChangedHandler(PaymentMethodModel_ActivePaymentMethodChanged);
            this.PaymentModel.ProcessPaymentComplete     += new ProcessPaymentCompleteHandler(PaymentModel_ProcessPaymentComplete);

            if (!ConfigurationProvider.DefaultProvider.ShowCreateAccount &&
                !ConfigurationProvider.DefaultProvider.PasswordIsOptionalDuringCheckout)
            {
                throw new Exception(StringResourceProvider.GetString("smartcheckout.aspx.129"));
            }

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            // Setup payment events
            PaymentMethodBaseModel paymentMethod = null;

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && (this.PaymentModel.ActivePaymentMethod == null || this.PaymentModel.ActivePaymentMethod.Name.ToLower() != PaymentType.CheckoutByAmazon.ToString().ToLower()))
            {
                this.PaymentModel.SetActivePaymentMethod(PaymentType.CheckoutByAmazon.ToString());
            }
            else
            {
                paymentMethod = this.PaymentModel.PaymentMethods.FirstOrDefault(pm => pm.Key == PaymentType.CreditCard).Value;
                if (paymentMethod != null)
                {
                    this.CreditCardModel = (CreditCardPaymentModel)paymentMethod;
                    this.CreditCardModel.BillingEqualsShippingChanged += new BillingEqualsShippingChangedHandler(CreditCardModel_BillingEqualsShippingChanged);
                }
            }

            // registered payment data changed events
            foreach (var kvp in this.PaymentModel.PaymentMethods)
            {
                var method = kvp.Value;
                method.PaymentDataChanged += new PaymentDataChangedHandler(PaymentModel_PaymentDataChanged);
            }

            // Create payment views
            this.PaymentView.StringResourceProvider = this.StringResourceProvider;
            this.PaymentView.SetModel(this.PaymentModel);

            this.BillingAddressEditView = this.PaymentView.BillingAddressEditView;
            this.BillingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressEditView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressStaticView = this.PaymentView.BillingAddressStaticView;
            this.BillingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressStaticView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressBookView = this.PaymentView.AddressBookView;
            this.BillingAddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressBookView.SetModel(this.AccountModel);

            this.AccountModel.PrimaryShippingAddressChanged += new PrimaryShippingAddressChangedHandler(AccountModel_PrimaryShippingAddressChanged);
            this.AccountModel.PrimaryBillingAddressChanged  += new PrimaryBillingAddressChangedHandler(AccountModel_PrimaryBillingAddressChanged);

            this.CustomerServiceModel = modelFactory.CreateContentModel();
            this.CustomerServiceModel.LoadContext(Vortx.OnePageCheckout.Settings.ConfigurationProvider.DefaultProvider.CustomerServiceTopic);
            this.CustomerServicePanel.StringResourceProvider = this.StringResourceProvider;
            this.CustomerServicePanel.SetModel(this.CustomerServiceModel);
            this.CustomerServicePanel.Initialize();
            this.CustomerServicePanel.Show();
            this.CustomerServicePanel.BindView();

            // if billing equals shipping then copy the shipping address to the billing address
            // TODO: evaluate whether or not this logic is neccessary
            if (this.PaymentModel.ActivePaymentMethod != null)
            {
                if (this.PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.CreditCard)
                {
                    if (this.CreditCardModel != null)
                    {
                        if (this.ShoppingCartModel.ShippingRequired && this.CreditCardModel.BillingEqualsShipping)
                        {
                            this.AccountModel.CopyShippingAddressToBilling();
                        }
                    }
                }
            }

            if (ConfigurationProvider.DefaultProvider.RequireTermsAndConditions)
            {
                IContentModel termsModel = modelFactory.CreateContentModel();
                termsModel.LoadContext(ConfigurationProvider.DefaultProvider.TermsAndConditionsTopicName);
                ContentPanelTerms.StringResourceProvider = this.StringResourceProvider;
                ContentPanelTerms.SetModel(termsModel);
                ContentPanelTerms.BindView();
            }

            if (!Page.IsPostBack)
            {
                this.InitializePage();

                string error = Request.QueryString["error"];
                if (error != null && error.Equals("true"))
                {
                    this.PaymentView.ShowError(StringResourceProvider.GetString("smartcheckout.aspx.130"));
                }

                Page.DataBind();
            }

            StylesheetLiteral.Text = "<link rel=\"stylesheet\" href=\"OPCControls/" + ConfigurationProvider.DefaultProvider.OPCStyleSheetName + "\" />";

            this.UpdatePanelOnePageCheckoutMain.Update();

            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "registerBuySafeKickers", "try{WriteBuySafeKickers();}catch(err){}", true);
            if (ConfigurationProvider.DefaultProvider.BuySafeEnabled)
            {
                OPC_BuySafeWrap.Attributes.Add("style", "height:102px;");
            }
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.Expires = -1;
            Response.AddHeader("pragma", "no-cache");
            Response.AddHeader("Last-Modified", DateTime.Now.AddMinutes(-10).ToUniversalTime() + " GMT");
            Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // HTTP/1.1
            Response.AddHeader("Cache-Control", "post-check=0, pre-check=0");
            Response.AddHeader("Pragma", "no-cache");                                   // HTTP/1.0
            ErrorMessage err;

            if (AppLogic.AppConfigBool("RequireOver13Checked") && !ThisCustomer.IsOver13)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkout.over13required", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
            }

            RequireSecurePage();

            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------
            ThisCustomer.RequireCustomerRecord();

            if (!ThisCustomer.IsRegistered)
            {
                bool boolAllowAnon = (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && !cart.HasRecurringComponents());
                if (!boolAllowAnon && ThisCustomer.PrimaryBillingAddressID > 0)
                {
                    Address BillingAddress = new Address();
                    BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                    if (BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpress || BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpressMark)
                    {
                        boolAllowAnon = AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout");
                    }
                }

                if (!boolAllowAnon)
                {
                    Response.Redirect("createaccount.aspx?checkout=true");
                }
            }
            if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.2", SkinID, ThisCustomer.LocaleSetting))); //checkout not allowed without primary shipping/billing addy
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            SectionTitle = AppLogic.GetString("checkoutshippingmult.aspx.1", SkinID, ThisCustomer.LocaleSetting); //shipping options

            cart.ValidProceedCheckout();                                                                          // will not come back from this if any issue. they are sent back to the cart page!

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            if (cart.IsAllDownloadComponents() || !Shipping.MultiShipEnabled() || cart.TotalQuantity() > AppLogic.MultiShipMaxNumItemsAllowed() || !cart.CartAllowsShippingMethodSelection || checkoutByAmazon.IsCheckingOut)
            {
                // not allowed then:
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutshippingmult.aspx.12", SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            CartItem FirstCartItem            = (CartItem)cart.CartItems[0];
            Address  FirstItemShippingAddress = new Address();

            FirstItemShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, FirstCartItem.ShippingAddressID, AddressTypes.Shipping);
            if (FirstItemShippingAddress.AddressID == 0)
            {
                // not allowed here anymore!
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutshippingmult.aspx.10", SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
            }

            if (!IsPostBack && CommonLogic.FormCanBeDangerousContent("update") == "" && CommonLogic.FormCanBeDangerousContent("continue") == "" && CommonLogic.QueryStringCanBeDangerousContent("setallprimary") == "")
            {
                UpdatepageContent();
            }

            if (CommonLogic.FormCanBeDangerousContent("update") != "" || CommonLogic.FormCanBeDangerousContent("continue") != "" || CommonLogic.QueryStringCanBeDangerousContent("setallprimary") != "")
            {
                ProcessCart();
            }
            JSPopupRoutines.Text = AppLogic.GetJSPopupRoutines();

            AppLogic.eventHandler("CheckoutShipping").CallEvent("&CheckoutShipping=true");
        }
        private void InitializePageContent()
        {
            if (Checkout)
            {
                pnlCheckoutImage.Visible = true;
                CheckoutImage.ImageUrl   = AppLogic.LocateImageURL("~/App_Themes/skin_" + SkinID.ToString() + "/images/step_2.gif");
            }

            if (CommonLogic.QueryStringNativeInt("errormsg") > 0)
            {
                ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));
                pnlErrorMsg.Controls.Add(new LiteralControl(String.Format("<b style='color:red;'>{0}</b><br /><br />", e.Message)));
            }

            if (Checkout && !ThisCustomer.IsRegistered)
            {
                Signin.Text = "<p align=\"left\">" + AppLogic.GetString("createaccount.aspx.3", SkinID, ThisCustomer.LocaleSetting) + " <a href=\"signin.aspx?checkout=" + CommonLogic.QueryStringBool("checkout").ToString().ToLowerInvariant() + "&returnURL=" + Server.UrlEncode(CommonLogic.IIF(Checkout, "shoppingcart.aspx?checkout=true", "account.aspx")) + "\"><b>" + AppLogic.GetString("createaccount.aspx.4", SkinID, ThisCustomer.LocaleSetting) + "</b></a>.</p>";
            }

            //if the customer already has entered a password don't ask them for another one
            Password p = new Password("", ThisCustomer.SaltKey);

            ctrlAccount.ShowPassword = (ThisCustomer.Password == "" || ThisCustomer.Password == p.SaltedPassword);

            ctrlAccount.Over13            = ThisCustomer.IsOver13;
            ctrlAccount.VATRegistrationID = ThisCustomer.VATRegistrationID;

            //Account Info
            if (!SkipRegistration)
            {
                pnlAccountInfo.Visible   = true;
                accountinfo_gif.ImageUrl = AppLogic.LocateImageURL("~/App_Themes/Skin_" + SkinID.ToString() + "/images/accountinfo.gif");


                if (ViewState["custpwd"] == null)
                {
                    ctrlAccount.txtPassword.TextMode        = TextBoxMode.Password;
                    ctrlAccount.txtPasswordConfirm.TextMode = TextBoxMode.Password;
                }
                if (Checkout && (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") || AppLogic.AppConfigBool("HidePasswordFieldDuringCheckout")))
                {
                    ctrlAccount.PasswordValidator.Visible = false;
                    ctrlAccount.PasswordValidator.Enabled = false;
                }
                ctrlAccount.ShowOver13 = AppLogic.AppConfigBool("RequireOver13Checked");
                if (!AppLogic.AppConfigBool("Vat.Enabled") || AppLogic.ProductIsMLExpress() == true)
                {
                    ctrlAccount.ShowVATRegistrationID = false;
                }

                if (!IsPostBack)
                {
                    ctrlAccount.FirstName = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.FirstName.Length != 0, ThisCustomer.FirstName, BillingAddress.FirstName));
                    ctrlAccount.LastName  = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.LastName.Length != 0, ThisCustomer.LastName, BillingAddress.LastName));

                    String emailx = ThisCustomer.EMail;

                    ctrlAccount.Email = Server.HtmlEncode(emailx).ToLowerInvariant().Trim();

                    ctrlAccount.Phone = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.Phone.Length != 0, ThisCustomer.Phone, BillingAddress.Phone));
                    // Create a phone validation error message

                    ctrlAccount.OKToEmailYes = (ThisCustomer.EMail.Length != 0);
                    ctrlAccount.OKToEmailNo  = !ctrlAccount.OKToEmailYes;
                }
            }
            else
            {
                valReqSkipRegEmail.Enabled = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("AnonCheckoutReqEmail");
                String emailx = ThisCustomer.EMail;
                txtSkipRegEmail.Text = Server.HtmlEncode(emailx).ToLowerInvariant().Trim();

                Literal2.Visible      = AppLogic.AppConfigBool("RequireOver13Checked");
                SkipRegOver13.Visible = AppLogic.AppConfigBool("RequireOver13Checked");

                SkipRegOver13.Checked        = ThisCustomer.IsOver13;
                pnlSkipReg.Visible           = true;
                createaccountaspx30.Visible  = false;
                BillingEqualsAccount.Visible = false;
                createaccountaspx31.Visible  = false;
            }

            if (!IsPostBack)
            {
                //Billing Info
                tblBillingInfo.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor"));
                tblBillingInfoBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle"));

                if (AllowShipToDifferentThanBillTo)
                {
                    billinginfo_gif.ImageUrl = AppLogic.LocateImageURL("~/App_Themes/Skin_" + SkinID.ToString() + "/images/billinginfo.gif");
                }
                else
                {
                    billinginfo_gif.ImageUrl = AppLogic.LocateImageURL("~/App_Themes/Skin_" + SkinID.ToString() + "/images/shippingandbillinginfo.gif");
                }

                createaccountaspx31.Text = AppLogic.GetString("createaccount.aspx.31", SkinID, ThisCustomer.LocaleSetting);
                if (AllowShipToDifferentThanBillTo)
                {
                    createaccountaspx30.Text = AppLogic.GetString("createaccount.aspx.30", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    createaccountaspx30.Text = AppLogic.GetString("createaccount.aspx.32", SkinID, ThisCustomer.LocaleSetting);
                }

                ctrlBillingAddress.NickName      = Server.HtmlEncode(ctrlBillingAddress.NickName);
                ctrlBillingAddress.FirstName     = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.FirstName.Length != 0, ThisCustomer.FirstName, BillingAddress.FirstName));
                ctrlBillingAddress.LastName      = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.LastName.Length != 0, ThisCustomer.LastName, BillingAddress.LastName));
                ctrlBillingAddress.PhoneNumber   = Server.HtmlEncode(BillingAddress.Phone);
                ctrlBillingAddress.Company       = Server.HtmlEncode(BillingAddress.Company);
                ctrlBillingAddress.ResidenceType = BillingAddress.ResidenceType.ToString();
                ctrlBillingAddress.Address1      = Server.HtmlEncode(BillingAddress.Address1);
                ctrlBillingAddress.Address2      = Server.HtmlEncode(BillingAddress.Address2);
                ctrlBillingAddress.Suite         = Server.HtmlEncode(BillingAddress.Suite);
                ctrlBillingAddress.State         = Server.HtmlEncode(BillingAddress.State);
                ctrlBillingAddress.City          = Server.HtmlEncode(BillingAddress.City);
                ctrlBillingAddress.ZipCode       = BillingAddress.Zip;
                ctrlBillingAddress.ShowZip       = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlBillingAddress.Country));

                //Shipping Info
                if (AllowShipToDifferentThanBillTo)
                {
                    pnlShippingInfo.Visible = true;
                    tblShippingInfo.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor"));
                    tblShippingInfoBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle"));
                    shippinginfo_gif.ImageUrl = AppLogic.LocateImageURL("~/App_Themes/Skin_" + SkinID.ToString() + "/images/shippinginfo.gif");

                    ctrlShippingAddress.NickName      = Server.HtmlEncode(ShippingAddress.NickName);
                    ctrlShippingAddress.FirstName     = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.FirstName.Length != 0, ThisCustomer.FirstName, BillingAddress.FirstName));
                    ctrlShippingAddress.LastName      = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.LastName.Length != 0, ThisCustomer.LastName, BillingAddress.LastName));
                    ctrlShippingAddress.PhoneNumber   = Server.HtmlEncode(ShippingAddress.Phone);
                    ctrlShippingAddress.Company       = Server.HtmlEncode(ShippingAddress.Company);
                    ctrlShippingAddress.ResidenceType = ShippingAddress.ResidenceType.ToString();
                    ctrlShippingAddress.Address1      = Server.HtmlEncode(ShippingAddress.Address1);
                    ctrlShippingAddress.Address2      = Server.HtmlEncode(ShippingAddress.Address2);
                    ctrlShippingAddress.Suite         = Server.HtmlEncode(ShippingAddress.Suite);
                    ctrlShippingAddress.City          = Server.HtmlEncode(ShippingAddress.City);
                    ctrlShippingAddress.State         = Server.HtmlEncode(ShippingAddress.State);
                    ctrlShippingAddress.ZipCode       = ShippingAddress.Zip;
                    ctrlShippingAddress.ShowZip       = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlShippingAddress.Country));
                }
            }

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (checkoutByAmazon.IsCheckingOut)
            {
                pnlAccountInfo.Visible = !ThisCustomer.IsRegistered && !SkipRegistration;

                pnlBillingInfo.Visible      =
                    pnlShippingInfo.Visible = false;

                pnlCBAAddressWidget.Visible = true;

                litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidget("CBAAddressWidgetContainer", false, String.Empty, new Guid(ThisCustomer.CustomerGUID), 300, 200);
                litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();
            }

            if (!ThisCustomer.IsRegistered)
            {
                if (SkipRegistration)
                {
                    btnContinueCheckout.Text = CommonLogic.IIF(Checkout, AppLogic.GetString("createaccount.aspx.76", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("createaccount.aspx.75", SkinID, ThisCustomer.LocaleSetting));
                }
                else
                {
                    btnContinueCheckout.Text = CommonLogic.IIF(Checkout, AppLogic.GetString("createaccount.aspx.74", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("createaccount.aspx.75", SkinID, ThisCustomer.LocaleSetting));
                }
            }
            else
            {
                btnContinueCheckout.Text = AppLogic.GetString("account.aspx.60", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }

            GetJavaScriptFunctions();
            AppLogic.GetButtonDisable(this.btnContinueCheckout, this.btnContinueCheckout.ValidationGroup);
        }
Exemplo n.º 20
0
        private void InitializePageContent()
        {
            if (CommonLogic.QueryStringNativeInt("errormsg") > 0)
            {
                ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));
                lblErrorMessage.Text = string.Format("<div class='error-large'>{0}</div>", e.Message);
                pnlErrorMsg.Visible  = true;
            }

            if (Checkout && !ThisCustomer.IsRegistered)
            {
                ltSignin.Text = "<div class='page-row signin-row'>" + AppLogic.GetString("createaccount.aspx.3", SkinID, ThisCustomer.LocaleSetting) + " <a href=\"signin.aspx?checkout=" + CommonLogic.QueryStringBool("checkout").ToString().ToLowerInvariant() + "&returnURL=" + Server.UrlEncode(CommonLogic.IIF(Checkout, "shoppingcart.aspx?checkout=true", "account.aspx")) + "\">" + AppLogic.GetString("createaccount.aspx.4", SkinID, ThisCustomer.LocaleSetting) + "</a>.</div>";
            }

            //if the customer already has entered a password don't ask them for another one
            Password p = new Password("", ThisCustomer.SaltKey);

            ctrlAccount.ShowPassword = (ThisCustomer.Password == "" || ThisCustomer.Password == p.SaltedPassword);

            ctrlAccount.Over13            = ThisCustomer.IsOver13;
            ctrlAccount.VATRegistrationID = ThisCustomer.VATRegistrationID;

            //Account Info
            if (!SkipRegistration)
            {
                pnlAccountInfo.Visible = true;

                if (ViewState["custpwd"] == null)
                {
                    ctrlAccount.txtPassword.TextMode        = TextBoxMode.Password;
                    ctrlAccount.txtPasswordConfirm.TextMode = TextBoxMode.Password;
                }

                ShoppingCart cart = new ShoppingCart(ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

                if (Checkout && !cart.HasRecurringComponents() && (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") || AppLogic.AppConfigBool("HidePasswordFieldDuringCheckout")))
                {
                    ctrlAccount.PasswordValidator.Visible = false;
                    ctrlAccount.PasswordValidator.Enabled = false;
                }
                ctrlAccount.ShowOver13 = AppLogic.AppConfigBool("RequireOver13Checked");
                if (!AppLogic.AppConfigBool("Vat.Enabled"))
                {
                    ctrlAccount.ShowVATRegistrationID = false;
                }

                if (!IsPostBack)
                {
                    ctrlAccount.FirstName = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.FirstName.Length != 0, ThisCustomer.FirstName, BillingAddress.FirstName));
                    ctrlAccount.LastName  = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.LastName.Length != 0, ThisCustomer.LastName, BillingAddress.LastName));

                    String emailx = ThisCustomer.EMail;

                    ctrlAccount.Email = Server.HtmlEncode(emailx).ToLowerInvariant().Trim();

                    ctrlAccount.Phone = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.Phone.Length != 0, ThisCustomer.Phone, BillingAddress.Phone));
                    // Create a phone validation error message

                    ctrlAccount.OKToEmailYes = (ThisCustomer.EMail.Length != 0);
                    ctrlAccount.OKToEmailNo  = !ctrlAccount.OKToEmailYes;
                }
            }
            else
            {
                valReqSkipRegEmail.Enabled = AppLogic.AppConfigBool("AnonCheckoutReqEmail");
                String emailx = ThisCustomer.EMail;
                txtSkipRegEmail.Text = Server.HtmlEncode(emailx).ToLowerInvariant().Trim();

                Literal2.Visible      = AppLogic.AppConfigBool("RequireOver13Checked");
                SkipRegOver13.Visible = AppLogic.AppConfigBool("RequireOver13Checked");

                SkipRegOver13.Checked        = ThisCustomer.IsOver13;
                pnlSkipReg.Visible           = true;
                createaccountaspx30.Visible  = false;
                BillingEqualsAccount.Visible = false;
                createaccountaspx31.Visible  = false;
            }

            if (!IsPostBack)
            {
                createaccountaspx31.Text = AppLogic.GetString("createaccount.aspx.31", SkinID, ThisCustomer.LocaleSetting);
                if (AllowShipToDifferentThanBillTo)
                {
                    createaccountaspx30.Text = AppLogic.GetString("createaccount.aspx.30", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    createaccountaspx30.Text = AppLogic.GetString("createaccount.aspx.32", SkinID, ThisCustomer.LocaleSetting);
                }

                ctrlBillingAddress.NickName      = Server.HtmlEncode(ctrlBillingAddress.NickName);
                ctrlBillingAddress.FirstName     = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.FirstName.Length != 0, ThisCustomer.FirstName, BillingAddress.FirstName));
                ctrlBillingAddress.LastName      = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.LastName.Length != 0, ThisCustomer.LastName, BillingAddress.LastName));
                ctrlBillingAddress.PhoneNumber   = Server.HtmlEncode(BillingAddress.Phone);
                ctrlBillingAddress.Company       = Server.HtmlEncode(BillingAddress.Company);
                ctrlBillingAddress.ResidenceType = BillingAddress.ResidenceType.ToString();
                ctrlBillingAddress.Address1      = Server.HtmlEncode(BillingAddress.Address1);
                ctrlBillingAddress.Address2      = Server.HtmlEncode(BillingAddress.Address2);
                ctrlBillingAddress.Suite         = Server.HtmlEncode(BillingAddress.Suite);
                ctrlBillingAddress.State         = Server.HtmlEncode(BillingAddress.State);
                ctrlBillingAddress.City          = Server.HtmlEncode(BillingAddress.City);
                ctrlBillingAddress.ZipCode       = BillingAddress.Zip;
                ctrlBillingAddress.ShowZip       = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlBillingAddress.Country));

                //Shipping Info
                if (AllowShipToDifferentThanBillTo)
                {
                    pnlShippingInfo.Visible           = true;
                    ctrlShippingAddress.NickName      = Server.HtmlEncode(ShippingAddress.NickName);
                    ctrlShippingAddress.FirstName     = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.FirstName.Length != 0, ThisCustomer.FirstName, BillingAddress.FirstName));
                    ctrlShippingAddress.LastName      = Server.HtmlEncode(CommonLogic.IIF(ThisCustomer.LastName.Length != 0, ThisCustomer.LastName, BillingAddress.LastName));
                    ctrlShippingAddress.PhoneNumber   = Server.HtmlEncode(ShippingAddress.Phone);
                    ctrlShippingAddress.Company       = Server.HtmlEncode(ShippingAddress.Company);
                    ctrlShippingAddress.ResidenceType = ShippingAddress.ResidenceType.ToString();
                    ctrlShippingAddress.Address1      = Server.HtmlEncode(ShippingAddress.Address1);
                    ctrlShippingAddress.Address2      = Server.HtmlEncode(ShippingAddress.Address2);
                    ctrlShippingAddress.Suite         = Server.HtmlEncode(ShippingAddress.Suite);
                    ctrlShippingAddress.City          = Server.HtmlEncode(ShippingAddress.City);
                    ctrlShippingAddress.State         = Server.HtmlEncode(ShippingAddress.State);
                    ctrlShippingAddress.ZipCode       = ShippingAddress.Zip;
                    ctrlShippingAddress.ShowZip       = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlShippingAddress.Country));
                }

                //if (!Checkout)
                //{
                //    //hide billing and shipping inputs in case of Checkout
                //    pnlBillingInfo.Visible = false;
                //    pnlShippingInfo.Visible = false;
                //}

                // Hide billing and shipping inputs w.r.t mock-ups
                pnlBillingInfo.Visible  = false;
                pnlShippingInfo.Visible = false;
            }

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (checkoutByAmazon.IsCheckingOut)
            {
                pnlAccountInfo.Visible = !ThisCustomer.IsRegistered && !SkipRegistration;

                pnlBillingInfo.Visible      =
                    pnlShippingInfo.Visible = false;

                pnlCBAAddressWidget.Visible = true;

                litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidget("CBAAddressWidgetContainer", false, String.Empty, new Guid(ThisCustomer.CustomerGUID), 300, 200);
                litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();
            }

            if (!ThisCustomer.IsRegistered)
            {
                if (SkipRegistration)
                {
                    btnContinueCheckout.Text = CommonLogic.IIF(Checkout, AppLogic.GetString("createaccount.aspx.76", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("createaccount.aspx.75", SkinID, ThisCustomer.LocaleSetting));
                }
                else
                {
                    btnContinueCheckout.Text = CommonLogic.IIF(Checkout, AppLogic.GetString("createaccount.aspx.74", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("createaccount.aspx.75", SkinID, ThisCustomer.LocaleSetting));
                }
            }
            else
            {
                btnContinueCheckout.Text = AppLogic.GetString("account.aspx.60", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }

            GetJavaScriptFunctions();
            AppLogic.GetButtonDisable(this.btnContinueCheckout, this.btnContinueCheckout.ValidationGroup);
        }
Exemplo n.º 21
0
        protected override void OnInit(EventArgs e)
        {
            int CustomerID  = ThisCustomer.CustomerID;
            int OrderNumber = CommonLogic.QueryStringUSInt("OrderNumber");

            StringBuilder output = new StringBuilder();

            // ----------------------------------------------------------------------------------------
            // WRITE OUT ANY HEADER CHECKOUT SEQUENCE GRAPHIC:
            // ----------------------------------------------------------------------------------------
            output.Append("<div align=\"center\">");
            output.Append("<img src=\"" + AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/step_6.gif") + "\" width=\"550\" height=\"54\" border=\"0\" >\n");
            output.Append("</div>");

            if (CustomerID != 0 && OrderNumber != 0)
            {
                Order ord = new Order(OrderNumber, ThisCustomer.LocaleSetting);

                if (ThisCustomer.CustomerID != ord.CustomerID)
                {
                    Response.Redirect(SE.MakeDriverLink("ordernotfound"));
                }

                if (ThisCustomer.ThisCustomerSession["3DSecure.LookupResult"].Length > 0)
                {
                    DB.ExecuteSQL("update orders set CardinalLookupResult=" + DB.SQuote(ThisCustomer.ThisCustomerSession["3DSecure.LookupResult"]) + " where OrderNumber=" + OrderNumber.ToString());
                }
                ThisCustomer.ThisCustomerSession.Clear();

                String ReceiptURL = "receipt.aspx?ordernumber=" + OrderNumber.ToString() + "&customerid=" + CustomerID.ToString();

                bool orderexists;
                using (SqlConnection conn = DB.dbConn())
                {
                    conn.Open();
                    using (IDataReader rs = DB.GetRS("select * from dbo.orders where customerid=" + CustomerID.ToString() + " and ordernumber=" + OrderNumber.ToString(), conn))
                    {
                        orderexists = rs.Read();
                    }
                }

                if (orderexists)
                {
                    String PM                  = AppLogic.CleanPaymentMethod(ord.PaymentMethod);
                    String StoreName           = AppLogic.AppConfig("StoreName");
                    bool   UseLiveTransactions = AppLogic.AppConfigBool("UseLiveTransactions");

                    if (!ord.AlreadyConfirmed)
                    {
                        // check to see if this was an "admin edit order" and if so, cleanup the old order, as it was being replaced by this new order:
                        int EditingOrderNumber = base.EditingOrderImpersonation;
                        if (base.IsInImpersonation && EditingOrderNumber != 0)
                        {
                            Order editedOrder = new Order(EditingOrderNumber, Localization.GetDefaultLocale());
                            if (!editedOrder.HasBeenEdited && editedOrder.TransactionState == AppLogic.ro_TXStateAuthorized || editedOrder.TransactionState == AppLogic.ro_TXStateCaptured)
                            {
                                editedOrder.EditedOn           = System.DateTime.Now;
                                editedOrder.RelatedOrderNumber = OrderNumber;
                                // try void first, or refund if that doesn't work
                                if (Gateway.OrderManagement_DoVoid(editedOrder, Localization.GetDefaultLocale()) != AppLogic.ro_OK)
                                {
                                    Gateway.OrderManagement_DoFullRefund(editedOrder, Localization.GetDefaultLocale(), "Order Was Edited, New Order #: " + OrderNumber.ToString());
                                }
                            }
                            base.AdminImpersonatingCustomer.ThisCustomerSession.ClearVal("IGD_EDITINGORDER");
                        }

                        DB.ExecuteSQL("update Customer set OrderOptions=NULL, OrderNotes=NULL, FinalizationData=NULL where CustomerID=" + CustomerID.ToString());

                        AppLogic.SendOrderEMail(ThisCustomer, OrderNumber, false, PM, true, base.EntityHelpers, base.GetParser);
                    }

                    String XmlPackageName = AppLogic.AppConfig("XmlPackage.OrderConfirmationPage");
                    if (XmlPackageName.Length == 0)
                    {
                        XmlPackageName = "page.orderconfirmation.xml.config";
                    }

                    if (XmlPackageName.Length != 0)
                    {
                        output.Append(AppLogic.RunXmlPackage(XmlPackageName, base.GetParser, ThisCustomer, SkinID, String.Empty, "OrderNumber=" + OrderNumber.ToString(), true, true));
                    }

                    Order order = new Order(OrderNumber);

                    if (order.PaymentMethod.ToLower() == GatewayCheckoutByAmazon.CheckoutByAmazon.CBA_Gateway_Identifier.ToLower())
                    {
                        GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                        output.Append("<br /><br />");
                        output.Append(checkoutByAmazon.RenderOrderDetailWidget(OrderNumber));
                    }

                    if (!ord.AlreadyConfirmed)
                    {
                        if (AppLogic.ProductIsMLExpress() == false &&
                            AppLogic.AppConfigBool("IncludeGoogleTrackingCode"))
                        {
                            Topic GoogleTrackingCode = new Topic("GoogleTrackingCode");
                            if (GoogleTrackingCode.Contents.Length != 0)
                            {
                                output.Append(GoogleTrackingCode.Contents.Replace("(!ORDERTOTAL!)", Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.Total(true))).Replace("(!ORDERNUMBER!)", OrderNumber.ToString()).Replace("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString()));
                            }
                        }
                        if (AppLogic.AppConfigBool("IncludeOvertureTrackingCode"))
                        {
                            Topic OvertureTrackingCode = new Topic("OvertureTrackingCode");
                            if (OvertureTrackingCode.Contents.Length != 0)
                            {
                                output.Append(OvertureTrackingCode.Contents.Replace("(!ORDERTOTAL!)", Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.Total(true))).Replace("(!ORDERNUMBER!)", OrderNumber.ToString()).Replace("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString()));
                            }
                        }

                        Topic GeneralTrackingCode = new Topic("ConfirmationTracking");
                        if (GeneralTrackingCode.Contents.Length != 0)
                        {
                            output.Append(GeneralTrackingCode.Contents.Replace("(!ORDERTOTAL!)", Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.Total(true))).Replace("(!ORDERNUMBER!)", OrderNumber.ToString()).Replace("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString()));
                        }
                        if (AppLogic.ProductIsMLExpress() == false &&
                            AppLogic.AppConfigBool("Google.EcomOrderTrackingEnabled"))
                        {
                            output.Append(AppLogic.GetGoogleEComTrackingV2(ThisCustomer, true));
                        }

                        if (AppLogic.GlobalConfigBool("BuySafe.Enabled") && AppLogic.GlobalConfig("BuySafe.Hash").Length != 0)
                        {
                            output.AppendLine("");
                            output.AppendLine("<!-- BEGIN: buySAFE Guarantee--> ");
                            output.AppendLine("<script src=\"" + AppLogic.GlobalConfig("BuySafe.RollOverJSLocation") + "\"></script>");
                            output.AppendLine("<span id=\"BuySafeGuaranteeSpan\"></span>");
                            output.AppendLine("<script type=\"text/javascript\"> ");
                            output.AppendLine("    buySAFE.Hash = '" + AppLogic.GlobalConfig("BuySafe.Hash") + "';");
                            output.AppendLine("    buySAFE.Guarantee.order = \"" + OrderNumber.ToString() + "\"; ");
                            output.AppendLine("    buySAFE.Guarantee.total = \"" + Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.Total(true)) + "\"; ");
                            output.AppendLine("    buySAFE.Guarantee.email = \"" + ThisCustomer.EMail + "\"; ");
                            output.AppendLine("    WriteBuySafeGuarantee(\"JavaScript\"); ");
                            output.AppendLine("</script> ");
                            output.AppendLine("<!-- END: buySAFE Guarantee-->");
                        }
                    }
                    DB.ExecuteSQL("Update Orders set AlreadyConfirmed=1 where OrderNumber=" + OrderNumber.ToString());
                }
                else
                {
                    output.Append("<div align=\"center\">");
                    output.Append("<br/><br/><br/><br/><br/>");
                    output.Append(AppLogic.GetString("orderconfirmation.aspx.19", SkinID, ThisCustomer.LocaleSetting));
                    output.Append("<br/><br/><br/><br/><br/>");
                    output.Append("</div>");
                }

                if (!ord.AlreadyConfirmed) //only do this once
                {
                    //Low inventory notification
                    if (AppLogic.AppConfigBool("SendLowStockWarnings") && ord.TransactionIsCaptured()) //If delayed capture, we'll check this when the order is captured
                    {
                        List <int> purchasedVariants = new List <int>();
                        foreach (CartItem ci in ord.CartItems)
                        {
                            purchasedVariants.Add(ci.VariantID);
                        }

                        AppLogic.LowInventoryWarning(purchasedVariants);
                    }
                }
            }
            else
            {
                output.Append("<p><b>Error: Invalid Customer ID or Invalid Order Number</b></p>");
            }

            if (!ThisCustomer.IsRegistered || AppLogic.AppConfigBool("ForceSignoutOnOrderCompletion"))
            {
                if (AppLogic.AppConfigBool("SiteDisclaimerRequired"))
                {
                    Profile.SiteDisclaimerAccepted = string.Empty;
                }

                //V3_9 Kill the Authentication ticket.
                Session.Clear();
                Session.Abandon();
                FormsAuthentication.SignOut();
                ThisCustomer.Logout();
            }

            litOutput.Text = output.ToString();

            base.OnInit(e);
        }