Esempio n. 1
0
    /// <summary>
    /// Initializes the page.
    /// </summary>
    /// <remarks>This method runs on the first load of the page, and does NOT
    /// run on postbacks. If you want to run a method on PostBacks, override the
    /// Page_Load event</remarks>
    protected override void InitializePage()
    {
        base.InitializePage();

        preProcessedOrderPacket = PreprocessOrder();

        if (!preProcessedOrderPacket.ShippingMethodRequired)    // no shipping method needed
        {
            GoTo("EnterBillingInfo.aspx?useTransient=" + isTransient);
        }


        setupShipping();
    }
Esempio n. 2
0
    protected void loadDataFromConcierge(IConciergeAPIService proxy)
    {
        preProcessedOrder = proxy.PreProcessOrder(targetOrder).ResultValue;

        if (targetOrder == null || targetOrder.LineItems == null ||
            targetOrder.LineItems.Count == 0)
        {
            lblShoppingCartEmpty.Visible            = true;
            lblContinueShoppingInstructions.Visible = false;
            btnCheckout.Enabled    = false;
            gvShoppingCart.Visible = false;
            return;
        }

        gvShoppingCart.Visible    = true;
        gvShoppingCart.DataSource = GetCartItems();
        gvShoppingCart.DataBind();
        lblShoppingCartEmpty.Visible            = false;
        lblContinueShoppingInstructions.Visible = true;
    }
Esempio n. 3
0
    /// <summary>
    /// Initializes the page.
    /// </summary>
    /// <remarks>This method runs on the first load of the page, and does NOT
    /// run on postbacks. If you want to run a method on PostBacks, override the
    /// Page_Load event</remarks>
    protected override void InitializePage()
    {
        base.InitializePage();

        // let's preprocess and figure out whether we need shipping information
        using (var api = GetConciegeAPIProxy())
        {
            // MS-5176 - handle error messages in case product is restricted for any reason  (e.g. Member Only)
            var r = api.PreProcessOrder(targetOrder);

            if (!r.Success)
            {
                QueueBannerError(r.FirstErrorMessage);
                GoHome();
            }

            preProcessedOrderPacket = r.ResultValue;
        }

        if (preProcessedOrderPacket.CrossSellCandidates == null || preProcessedOrderPacket.CrossSellCandidates.Count == 0)
        {
            GoTo("EnterShippingInformation.aspx?useTransient=" + isTransient);
        }

        rptItems.DataSource = preProcessedOrderPacket.CrossSellCandidates;
        rptItems.DataBind();

        List <msOrderLineItem> csi = MultiStepWizards.PlaceAnOrder.CrossSellItems;

        if (csi != null &&
            csi.Count > 0)
        {
            pnlItems.Visible          = true;
            gvShoppingCart.DataSource = csi;
            gvShoppingCart.DataBind();
        }
    }
Esempio n. 4
0
 protected void preProcessOrder(IConciergeAPIService proxy)
 {
     preProcessedOrderPacket = proxy.PreProcessOrder(MultiStepWizards.PlaceAnOrder.ShoppingCart).ResultValue;
 }
Esempio n. 5
0
    private bool populateOrder()
    {
        if (targetOrder == null || targetOrder.LineItems == null ||
            targetOrder.LineItems.Count == 0)
        {
            lblShoppingCartEmpty.Visible = true;
            btnPlaceOrder.Enabled        = false;
            return(false);
        }

        // let's populate the order

        if (isTransient)
        {
            lbCancel.Enabled           = false; // you can't do this for a transient order - you have to proceed
            CancelOrderWrapper.Visible = false;

            lblContinueShoppingInstructions.Visible = false;
            hlChangeShippingMethod.NavigateUrl     += "?useTransient=true";
        }

        // we have to preprocess the order to get the prices and such
        //if (string.IsNullOrWhiteSpace(targetOrder.BillingEmailAddress))
        //    targetOrder.BillingEmailAddress = ConciergeAPI.CurrentEntity.EmailAddress;

        //if (string.IsNullOrWhiteSpace(targetOrder.BillingEmailAddress))
        //    targetOrder.BillingEmailAddress = ConciergeAPI.CurrentUser.EmailAddress;

        using (var api = GetConciegeAPIProxy())
        {
            if (targetOrder.BillTo != null && targetOrder.BillingAddress == null)
            {
                msEntity billTo = api.Get(targetOrder.BillTo).ResultValue.ConvertTo <msEntity>();
                if (billTo.Addresses != null && billTo.Addresses.Count > 0)
                {
                    var address = billTo.Addresses.FirstOrDefault(x => x.Type == billTo.PreferredAddressType) ??
                                  billTo.Addresses[0];

                    targetOrder.BillingAddress = address.Address;
                }
            }

            if (targetOrder.ShippingAddress == null && targetOrder.ShipTo != null)
            {
                msEntity shipTo = api.Get(targetOrder.ShipTo).ResultValue.ConvertTo <msEntity>();
                if (shipTo.Addresses != null && shipTo.Addresses.Count > 0)
                {
                    var address = shipTo.Addresses.FirstOrDefault(x => x.Type == shipTo.PreferredAddressType) ??
                                  shipTo.Addresses[0];

                    targetOrder.ShippingAddress = address.Address;
                }
            }

            //if it's still null just set the shipping address to the billing address - whatever it is (null is acceptable)
            if (targetOrder.ShippingAddress == null)
            {
                targetOrder.ShippingAddress = targetOrder.BillingAddress;
            }

            var csi = MultiStepWizards.PlaceAnOrder.CrossSellItems;
            if (csi != null && csi.Count > 0)
            {
                targetOrder.LineItems.AddRange(csi.FindAll(x => x.Quantity != 0)); // add any cross sell items
                hlChangeRemoveAdditionalItems.Visible      = true;
                hlChangeRemoveAdditionalItems.NavigateUrl += "?useTransient" + isTransient;
            }

            if (targetOrder.Date == DateTime.MinValue)
            {
                targetOrder.Date = DateTime.Now;
            }

            preProcessedOrderPacket = api.PreProcessOrder(targetOrder).ResultValue;
        }


        cleanOrder = preProcessedOrderPacket.FinalizedOrder.ConvertTo <msOrder>();

        // for display, we want to summarize shipping/taxes, so lets remove those items from the order
        List <msOrderLineItem> itemsToDisplay = new List <msOrderLineItem>(cleanOrder.LineItems);

        itemsToDisplay.RemoveAll(x => x.Type == OrderLineItemType.Shipping || x.Type == OrderLineItemType.Taxes || x.Type == OrderLineItemType.Discount);

        // let's hide the demographics warning
        divMissingDemographics.Visible = false;
        btnPlaceOrder.Enabled          = true;

        gvShoppingCart.DataSource = itemsToDisplay;
        gvShoppingCart.DataBind();
        lblShoppingCartEmpty.Visible = false;

        lblShipping.Text    = preProcessedOrderPacket.ShippingCharges.ToString("C");
        lblTaxes.Text       = preProcessedOrderPacket.Taxes.ToString("C");
        lblTotal.Text       = preProcessedOrderPacket.Total.ToString("C");
        lblDiscounts.Text   = preProcessedOrderPacket.Discount.ToString("C");
        lblTotalDueNow.Text = preProcessedOrderPacket.AmountDueNow.ToString("C");

        return(true);
    }
Esempio n. 6
0
    /// <summary>
    /// Initializes the target object for the page
    /// </summary>
    /// <remarks>Many pages have "target" objects that the page operates on. For instance, when viewing
    /// an event, the target object is an event. When looking up a directory, that's the target
    /// object. This method is intended to be overriden to initialize the target object for
    /// each page that needs it.</remarks>
    protected override void InitializeTargetObject()
    {
        hfOrderBillToId.Value = ConciergeAPI.CurrentEntity.ID;

        dvPriorityData.InnerHtml = GetPriorityPaymentsConfig(hfOrderBillToId.Value);

        base.InitializeTargetObject();

        if (IsTransient)
        {
            targetOrder = MultiStepWizards.PlaceAnOrder.TransientShoppingCart;
        }
        else
        {
            targetOrder = MultiStepWizards.PlaceAnOrder.ShoppingCart;
        }

        if (targetOrder == null)
        {
            QueueBannerError("Unable to checkout without an active shopping cart.");
            GoHome();
            return;
        }

        //MS-2823
        if (targetOrder.BillTo == null)
        {
            targetOrder.BillTo = hfOrderBillToId.Value;
        }

        if (targetOrder.ShipTo == null)
        {
            targetOrder.ShipTo = targetOrder.BillTo;
        }


        if (!IsPostBack)
        {
            // let's preprocess and figure out whether we need shipping information
            var completeOrder = targetOrder.Clone().ConvertTo <msOrder>();
            var csi           = MultiStepWizards.PlaceAnOrder.CrossSellItems;
            if (csi != null && csi.Count > 0)
            {
                completeOrder.LineItems.AddRange(csi.FindAll(x => x.Quantity != 0)); // add any cross sell items
            }
            if (completeOrder.Date == DateTime.MinValue)
            {
                completeOrder.Date = DateTime.Now;
            }

            using (var api = GetConciegeAPIProxy())
            {
                preProcessedOrderPacket = api.PreProcessOrder(completeOrder).ResultValue;
            }

            // no billing, but we want to test Total, and not AmountDueNow
            // because even if nothing is due now we need to capture credit card info
            if (preProcessedOrderPacket.Total == 0)
            {
                GoTo("ConfirmOrder.aspx?useTransient=" + IsTransient);
            }

            lblAmountDue.Text = preProcessedOrderPacket.AmountDueNow.ToString("C");

            using (var api = GetServiceAPIProxy())
                BillingInfoWidget.AllowableMethods = api.DetermineAllowableOrderPaymentMethods(preProcessedOrderPacket.FinalizedOrder.ConvertTo <msOrder>()).ResultValue;

            // let's set default payment info
            switch (targetOrder.PaymentMethod)
            {
            case OrderPaymentMethod.None:
                break;     // do nothing

            case OrderPaymentMethod.CreditCard:
                var cc = new CreditCard();
                // Do NOT keep the credit card information on the page unpon refreshes
                cc.SavePaymentMethod = targetOrder.SavePaymentMethod;
                cc.NameOnCard        = targetOrder.SafeGetValue <string>("NameOnCreditCard");
                BillingInfoWidget.SetPaymentInfo(cc);
                break;

            case OrderPaymentMethod.ElectronicCheck:
                var ec = new ElectronicCheck();
                ec.BankAccountNumber = targetOrder.ACHAccountNumber;
                ec.RoutingNumber     = targetOrder.ACHRoutingNumber;
                ec.SavePaymentMethod = targetOrder.SavePaymentMethod;
                BillingInfoWidget.SetPaymentInfo(ec);
                break;

            case OrderPaymentMethod.SavedPaymentMethod:
                var spi = new SavedPaymentInfo();
                spi.SavedPaymentMethodID = targetOrder.SavedPaymentMethod;
                BillingInfoWidget.SetPaymentInfo(spi);
                break;

            default:
                var nep = new NonElectronicPayment();
                nep._OrderPaymentMethod = targetOrder.PaymentMethod;
                nep.ReferenceNumber     = targetOrder.PaymentReferenceNumber;
                BillingInfoWidget.SetPaymentInfo(nep);
                break;
            }

            BillingInfoWidget.SetBillingAddress(targetOrder.BillingAddress);
        }
    }