Ejemplo n.º 1
0
    protected void uxNextButton_Click(object sender, EventArgs e)
    {
        string errMsg;

        if (!SetShippingCouponGiftDetails())
        {
            return;
        }

        StoreContext.CheckoutDetails.SetCustomerComments(uxCustomerComments.Text);
        StoreContext.CheckoutDetails.IsCreatedByAdmin = true;

        if (!uxSelectPaymentList.SetPayment(out errMsg))
        {
            uxMessage.DisplayError(errMsg);
            return;
        }

        SetSaleTaxExempt();

        if (StoreContext.GetOrderAmount().Total <= 0)
        {
            MainContext.RedirectMainControl("OrderCreateCheckOutSummary.ascx",
                                            String.Format("StoreID={0}&CurrencyCode={1}", SelectedStoreID, uxCurrencyControl.CurrentCurrencyCode));
        }
        else
        {
            MainContext.RedirectMainControl("OrderCreatePaymentDetails.ascx",
                                            String.Format("StoreID={0}&CurrencyCode={1}", SelectedStoreID, uxCurrencyControl.CurrentCurrencyCode));
        }
    }
Ejemplo n.º 2
0
    private void CalculateShippingCost(
        ShippingOption shippingOption,
        out decimal shippingCost,
        out decimal handlingFee)
    {
        OrderCalculator orderCalculator = new OrderCalculator();

        ShippingMethod shippingMethod = shippingOption.CreateNonRealTimeShippingMethod();

        if (StoreContext.CheckoutDetails.Coupon.DiscountType == Vevo.Domain.Discounts.Coupon.DiscountTypeEnum.FreeShipping)
        {
            shippingCost = 0;
        }
        else
        {
            shippingCost = orderCalculator.GetShippingCost(
                shippingMethod,
                StoreContext.ShoppingCart.SeparateCartItemGroups(),
                StoreContext.WholesaleStatus,
                StoreContext.GetOrderAmount().Discount)
                           + CartItemPromotion.GetShippingCostFromPromotion(shippingMethod,
                                                                            StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                                                            StoreContext.WholesaleStatus,
                                                                            StoreContext.GetOrderAmount().Discount);
        }

        handlingFee = orderCalculator.GetHandlingFee(
            shippingMethod,
            StoreContext.ShoppingCart.SeparateCartItemGroups(),
            StoreContext.WholesaleStatus);
    }
Ejemplo n.º 3
0
    private void ProcessOnWebsiteRequireOrderIDPayment(CheckoutDetails checkout)
    {
        OnWebsiteRequireOrderIDPaymentMethod payment = (OnWebsiteRequireOrderIDPaymentMethod)checkout.PaymentMethod;

        OrderNotifyService order = CreateOrder(checkout);

        PaymentAppGateway gateway  = new PaymentAppGateway(checkout);
        string            postData = gateway.CreateOnWebsitePaymentXml(
            StoreContext.Culture,
            StoreContext.GetOrderAmount().Total,
            order.OrderID,
            WebUtilities.GetVisitorIP(),
            UrlPath.StorefrontUrl,
            true);

        PaymentAppResult paymentResult = gateway.PostCommand(new HttpService(), postData, UrlPath.StorefrontUrl);

        if (paymentResult.Status == PaymentAppResult.PaymentStatus.OK)
        {
            ProcessCreditCardPaymentSuccess(
                order,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
Ejemplo n.º 4
0
    private string CreateParameterText(CheckoutDetails checkoutDetails, PayPalRedirectPaymentMethod paymentMethod)
    {
        NameValueCollection collection = paymentMethod.CreatePostParameters(
            checkoutDetails,
            StoreContext.Culture,
            StoreContext.Currency,
            StoreContext.ShoppingCart,
            UrlPath.StorefrontUrl,
            OrderID,
            StoreContext.GetOrderAmount().Total,
            StoreContext.WholesaleStatus,
            WebUtilities.GetVisitorIP()
            );

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < collection.Count; i++)
        {
            string text;
            if (paymentMethod.IsHiddenFieldUsingID)
            {
                text = CreateTagHiddenWithID(collection.GetKey(i), collection.Get(i));
            }
            else
            {
                text = CreateTagHidden(collection.GetKey(i), collection.Get(i));
            }

            sb.Append(text);
        }

        return(sb.ToString());
    }
Ejemplo n.º 5
0
    private void CreatePostParameters(CheckoutDetails checkout)
    {
        PaymentAppGateway gateway = new PaymentAppGateway(checkout);
        TwoCheckoutRedirectPaymentMethod twoCheckoutPaymentMethod = (TwoCheckoutRedirectPaymentMethod)checkout.PaymentMethod;
        string urlHidden = twoCheckoutPaymentMethod.GetPostedUrl();

        NameValueCollection collection = twoCheckoutPaymentMethod.CreatePostParameters(
            checkout,
            StoreContext.Culture,
            StoreContext.Currency,
            StoreContext.ShoppingCart,
            UrlPath.StorefrontUrl,
            OrderID,
            StoreContext.GetOrderAmount().Total,
            StoreContext.WholesaleStatus,
            WebUtilities.GetVisitorIP());

        uxLiteral.Text = CreateParameterText(collection, twoCheckoutPaymentMethod);

        string xmlData = gateway.CreateHostedPaymentXml(
            StoreContext.Culture,
            StoreContext.Currency,
            StoreContext.ShoppingCart,
            UrlPath.StorefrontUrl,
            OrderID,
            StoreContext.GetOrderAmount().Total,
            StoreContext.WholesaleStatus,
            WebUtilities.GetVisitorIP());

        HostedXml.Value           = HttpUtility.UrlEncode(xmlData);
        uxUrlHidden.Value         = urlHidden;
        uxRefreshLink.NavigateUrl = urlHidden;
    }
Ejemplo n.º 6
0
    private int GetRewardPoint()
    {
        OrderAmount     orderAmount = StoreContext.GetOrderAmount();
        OrderCalculator calculator  = new OrderCalculator();

        return(calculator.GetPointFromPrice((orderAmount.Subtotal - orderAmount.Discount), ConvertUtilities.ToDecimal(DataAccessContext.Configurations.GetValue("RewardPoints", StoreContext.CurrentStore))));
    }
Ejemplo n.º 7
0
    private void ProcessOnPayPalProUSPayment(CheckoutDetails checkout)
    {
        PayPalProUSPaymentMethod paypalPayment = (PayPalProUSPaymentMethod)checkout.PaymentMethod;
        bool                   result          = false;
        PaymentAppResult       paymentResult;
        RecurringPaymentResult recurringPaymentResult;
        ProcessPaymentService  process = ProcessPaymentService.CreateNew(new HttpService(), StoreContext.ShoppingCart);

        result = process.ProcessPayPalProUSPayment(
            StoreContext.GetOrderAmount().Total,
            DataAccessContext.CurrencyRepository.GetOne(DataAccessContext.Configurations.GetValue("PaymentCurrency")),
            StoreContext.Culture,
            checkout,
            StoreContext.ShoppingCart,
            StoreContext.Customer,
            UrlPath.StorefrontUrl,
            WebUtilities.GetVisitorIP(),
            out paymentResult,
            out recurringPaymentResult);

        if (result)
        {
            OrderCreateService orderCreateService = new OrderCreateService(
                StoreContext.ShoppingCart,
                StoreContext.CheckoutDetails,
                StoreContext.Culture,
                CurrenntCurrency,
                AffiliateHelper.GetAffiliateCode(),
                WebUtilities.GetVisitorIP(),
                recurringPaymentResult
                );

            Order       order;
            OrderAmount amount = orderCreateService.GetOrderAmount(StoreContext.Customer)
                                 .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                          StoreContext.CheckoutDetails,
                                          StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                          StoreContext.Customer));
            order = orderCreateService.PlaceOrder(amount, StoreContext.Customer, DataAccessContext.StoreRetriever, StoreContext.Culture);
            GiftRegistry.UpdateGiftRegistryQuantity(StoreContext.ShoppingCart, StoreContext.CheckoutDetails);
            CustomerRewardPoint.UpdateRedeemPoint(StoreContext.CheckoutDetails, StoreContext.Customer, order);

            OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID);

            ProcessCreditCardPaymentSuccess(
                orderBusiness,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
Ejemplo n.º 8
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (StoreContext.ShoppingCart.ContainsRecurringProduct())
        {
            if (!HasOnlyOneRecurringPayment())
            {
                uxMessage.DisplayError("Some payment methods are disabled because they cannot " +
                                       "be used with recurring payments of the product(s) in your shopping cart.");
            }
        }

        ICartItem[] cart = StoreContext.ShoppingCart.GetCartItems();
        if (cart.Length == 0)
        {
            MainContext.RedirectMainControl("OrderList.ascx");
        }

        PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
            CurrentCulture, StoreContext.CheckoutDetails.PaymentMethod.Name);

        if (!StoreContext.ShoppingCart.ContainsRecurringProduct())
        {
            if (StoreContext.GetOrderAmount().Total <= 0)
            {
                string paymentMethodName = PaymentOption.NoPaymentName;
                string secondaryName     = String.Empty;

                if (HasCoupon() || HasGiftCertificate())
                {
                    if (HasCoupon())
                    {
                        secondaryName += "Coupon";
                    }

                    if (HasGiftCertificate())
                    {
                        if (HasCoupon())
                        {
                            secondaryName += " / ";
                        }

                        secondaryName += "Gift Certificate";
                    }
                }
                PaymentOption zeroPaymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                    CurrentCulture, paymentMethodName);
                PaymentMethod paymentMethod = zeroPaymentOption.CreatePaymentMethod();
                paymentMethod.SecondaryName = secondaryName;
                StoreContext.CheckoutDetails.SetPaymentMethod(paymentMethod);
            }
        }
    }
Ejemplo n.º 9
0
    private void ProcessAnonymousPayment(CheckoutDetails checkout)
    {
        AnonymousPaymentMethod payment = (AnonymousPaymentMethod)checkout.PaymentMethod;

        ProcessPaymentResult paymentResult;
        bool result = payment.ProcessPayment(
            StoreContext.GetOrderAmount().Total,
            DataAccessContext.Configurations.GetValue("PaymentCurrency"),
            checkout,
            out paymentResult);

        if (result)
        {
            OrderCreateService orderCreateService = new OrderCreateService(
                StoreContext.ShoppingCart,
                checkout,
                StoreContext.Culture,
                StoreContext.Currency,
                AffiliateHelper.GetAffiliateCode(),
                WebUtilities.GetVisitorIP());

            OrderAmount orderAmount;
            Order       order = PlaceOrderAnonymous(
                (Page.User.Identity.IsAuthenticated) ? Membership.GetUser().UserName : SystemConst.AnonymousUser,
                orderCreateService,
                checkout, out orderAmount);

            AffiliateOrder affiliateorder = new AffiliateOrder();
            affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode();
            affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount);

            OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID);
            ProcessCreditCardPaymentSuccess(
                orderBusiness,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            CheckoutNotCompletePage.RedirectToPage(
                "Error Message",
                paymentResult.ErrorMessage,
                "ShoppingCart.aspx",
                "Return To Shopping Cart");
        }
    }
Ejemplo n.º 10
0
    private void ProcessHostedPayment(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        PaymentAppGateway gateway = new PaymentAppGateway(checkout);

        string xmlData = gateway.CreateHostedPaymentXml(
            StoreContext.Culture,
            CurrenntCurrency,
            StoreContext.ShoppingCart,
            UrlPath.StorefrontUrl,
            order.OrderID,
            StoreContext.GetOrderAmount().Total,
            StoreContext.WholesaleStatus,
            WebUtilities.GetVisitorIP());

        Response.Redirect("../Gateway/GatewayPosting.aspx?OrderID=" + order.OrderID);
    }
Ejemplo n.º 11
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        uxGiftCertificateTR.Visible = DataAccessContext.Configurations.GetBoolValue(
            "GiftCertificateEnabled");
        RefreshGrid();

        OrderAmount orderAmount = StoreContext.GetOrderAmount();

        uxProductCostLabel.Text       = CurrenntCurrency.FormatPrice(orderAmount.Subtotal);
        uxTaxLabel.Text               = CurrenntCurrency.FormatPrice(orderAmount.Tax);
        uxShippingCostLabel.Text      = CurrenntCurrency.FormatPrice(orderAmount.ShippingCost);
        uxHandlingFeeLabel.Text       = CurrenntCurrency.FormatPrice(orderAmount.HandlingFee);
        uxDiscountLabel.Text          = CurrenntCurrency.FormatPrice(orderAmount.Discount * -1);
        uxPointDiscountCostLabel.Text = CurrenntCurrency.FormatPrice(orderAmount.PointDiscount * -1);
        uxGiftCertificateLabel.Text   = CurrenntCurrency.FormatPrice(orderAmount.GiftCertificate * -1);
        uxTotalLabel.Text             = CurrenntCurrency.FormatPrice(orderAmount.Total);

        uxHandlingFeeTR.Visible  = DataAccessContext.Configurations.GetBoolValue("HandlingFeeEnabled");
        uxApplyCouponDiv.Visible = !DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode");
    }
Ejemplo n.º 12
0
    private void CreatePostParameters(CheckoutDetails checkout)
    {
        PaymentAppGateway gateway = new PaymentAppGateway(checkout);

        string urlHidden = PaymentAppGateway.GetPaymentAppUrl("/HostedRecordHtml.aspx", UrlPath.StorefrontUrl);

        string xmlData = gateway.CreateHostedPaymentXml(
            StoreContext.Culture,
            StoreContext.Currency,
            StoreContext.ShoppingCart,
            UrlPath.StorefrontUrl,
            OrderID,
            StoreContext.GetOrderAmount().Total,
            StoreContext.WholesaleStatus,
            WebUtilities.GetVisitorIP());

        HostedXml.Value           = HttpUtility.UrlEncode(xmlData);
        uxUrlHidden.Value         = urlHidden;
        uxRefreshLink.NavigateUrl = urlHidden;
    }
    private void PopulateControls()
    {
        OrderAmount orderAmount = StoreContext.GetOrderAmount();

        uxSubTotalValueLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Subtotal);
        uxTaxValueLabel.Text      = StoreContext.Currency.FormatPrice(orderAmount.Tax);

        decimal shippingCost = 0;

        if (orderAmount.ShippingCost > 0)
        {
            shippingCost           = orderAmount.ShippingCost;
            uxTotalValueLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Total);
        }
        else
        {
            uxTotalValueLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Total + shippingCost);
        }
        uxShippingValueLabel.Text = StoreContext.Currency.FormatPrice(shippingCost);

        PanelVisible(orderAmount.Discount * -1, uxDiscountPanel, uxDiscountValueLabel);
        PanelVisible(orderAmount.GiftCertificate * -1, uxGiftCertificatePanel, uxGiftCertificateValueLabel);

        if (DataAccessContext.Configurations.GetBoolValue("HandlingFeeEnabled"))
        {
            PanelVisible(orderAmount.HandlingFee, uxHandlingFeePanel, uxHandlingFeeValueLabel);
        }
        else
        {
            PanelVisible(0, uxHandlingFeePanel, uxHandlingFeeValueLabel);
        }

        if (DataAccessContext.Configurations.GetBoolValue("PointSystemEnabled", StoreContext.CurrentStore))
        {
            PanelVisible(orderAmount.PointDiscount * -1, uxPointDiscountPanel, uxPointDiscountValueLabel);
        }
        else
        {
            PanelVisible(0, uxPointDiscountPanel, uxPointDiscountValueLabel);
        }
    }
Ejemplo n.º 14
0
    private void ProcessOfflineCreditCardPayment(CheckoutDetails checkout)
    {
        PaymentAppGateway gateway  = new PaymentAppGateway(checkout);
        string            postData = gateway.CreateOnWebsitePaymentXml(
            StoreContext.Culture,
            StoreContext.GetOrderAmount().Total,
            "",
            WebUtilities.GetVisitorIP(),
            UrlPath.StorefrontUrl,
            true);

        PaymentAppResult paymentResult = gateway.PostCommand(new HttpService(), postData, UrlPath.StorefrontUrl);

        if (paymentResult.Status == PaymentAppResult.PaymentStatus.OK)
        {
            ProcessOfflinePaymentSuccess(checkout);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
Ejemplo n.º 15
0
 protected void uxSelectPaymentMethodButton_Click(object sender, EventArgs e)
 {
     uxPaymentNote.Visible = false;
     if (!SetShippingCouponGiftDetails())
     {
         return;
     }
     if (StoreContext.GetOrderAmount().Total <= 0)
     {
         uxPaymentNote.Visible                 = true;
         uxPaymentListPanel.Visible            = false;
         uxChangeCheckOutDatailsButton.Visible = true;
         uxSelectPaymentMethodButton.Visible   = false;
     }
     else
     {
         uxSelectPaymentList.CultureID = uxLanguageControl.CurrentCultureID;
         uxSelectPaymentList.PopulateControls();
         uxPaymentListPanel.Visible            = true;
         uxChangeCheckOutDatailsButton.Visible = true;
         uxSelectPaymentMethodButton.Visible   = false;
     }
 }
Ejemplo n.º 16
0
    private void ProcessOnPayPalProUSPayment(CheckoutDetails checkout)
    {
        PayPalProUSPaymentMethod paypalPayment = (PayPalProUSPaymentMethod)checkout.PaymentMethod;
        bool                   result          = false;
        PaymentAppResult       paymentResult;
        RecurringPaymentResult recurringPaymentResult;
        ProcessPaymentService  process = ProcessPaymentService.CreateNew(new HttpService(), StoreContext.ShoppingCart);

        result = process.ProcessPayPalProUSPayment(
            StoreContext.GetOrderAmount().Total,
            DataAccessContext.CurrencyRepository.GetOne(DataAccessContext.Configurations.GetValue("PaymentCurrency")),
            StoreContext.Culture,
            checkout,
            StoreContext.ShoppingCart,
            StoreContext.Customer,
            UrlPath.StorefrontUrl,
            WebUtilities.GetVisitorIP(),
            out paymentResult,
            out recurringPaymentResult);

        if (result)
        {
            OrderCreateService orderCreateService = new OrderCreateService(
                StoreContext.ShoppingCart,
                StoreContext.CheckoutDetails,
                StoreContext.Culture,
                StoreContext.Currency,
                AffiliateHelper.GetAffiliateCode(),
                WebUtilities.GetVisitorIP(),
                recurringPaymentResult
                );

            Order       order;
            OrderAmount orderAmount;
            if (!IsAnonymousCheckout())
            {
                order = PlaceOrder(orderCreateService, out orderAmount);
            }
            else
            {
                order = PlaceOrderAnonymous(SystemConst.UnknownUser, orderCreateService, checkout, out orderAmount);
            }

            AffiliateOrder affiliateorder = new AffiliateOrder();
            affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode();
            affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount);

            OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID);

            ProcessCreditCardPaymentSuccess(
                orderBusiness,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
Ejemplo n.º 17
0
    public bool SetPayment(out string errMsg)
    {
        errMsg = String.Empty;
        string        paymentMethodName;
        PaymentMethod paymentMethod;

        if (StoreContext.GetOrderAmount().Total <= 0)
        {
            paymentMethodName = PaymentOption.NoPaymentName;
            string secondaryName = String.Empty;

            if (HasCoupon() || HasGiftCertificate())
            {
                if (HasCoupon())
                {
                    secondaryName += "Coupon";
                }

                if (HasGiftCertificate())
                {
                    if (HasCoupon())
                    {
                        secondaryName += " / ";
                    }

                    secondaryName += "Gift Certificate";
                }
            }
            PaymentOption zeroPaymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                StoreContext.Culture, paymentMethodName);
            paymentMethod = zeroPaymentOption.CreatePaymentMethod();
            paymentMethod.SecondaryName = secondaryName;
            StoreContext.CheckoutDetails.SetPaymentMethod(paymentMethod);

            return(true);
        }


        if (!IsAnyPaymentSelected())
        {
            errMsg = "Please correct the following errors :";
            uxPaymentMethodMessageLabel.Text  = "Please select payment method.";
            uxPaymentMethodMessageDiv.Visible = true;
            return(false);
        }

        paymentMethodName = GetSelectedPaymentName();
        PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
            CurrentCulture, paymentMethodName);

        paymentMethod = paymentOption.CreatePaymentMethod();
        paymentMethod.SecondaryName = GetSecondaryPaymentName();

        string poNumber = String.Empty;

        if (IsPONumberEmpty(out poNumber))
        {
            errMsg = "Please input purchase order number.";
            uxPaymentMethodMessageLabel.Text  = errMsg;
            uxPaymentMethodMessageDiv.Visible = true;
            return(false);
        }

        paymentMethod.PONumber = poNumber;
        StoreContext.CheckoutDetails.SetPaymentMethod(paymentMethod);

        return(true);
    }
Ejemplo n.º 18
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (GetShippingOptionAmount() <= 0)
        {
            SwitchPanelByState(CheckoutPageState.Error);
            uxValidateMessage.DisplayError("[$NoShippingOptionError]");
            return;
        }
        if (GetPaymentGatewayAmount() <= 0)
        {
            SwitchPanelByState(CheckoutPageState.Error);
            uxValidateMessage.DisplayError("[$NoPaymentGatewayError]");
            return;
        }

        if (CurrentState == CheckoutPageState.ShippingAddress)
        {
            if (!Roles.IsUserInRole("Customers") && !IsAnonymousCheckout())
            {
                Response.Redirect("UserLogin.aspx?ReturnUrl=Checkout.aspx");
            }

            if (!DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode"))
            {
                uxCheckoutShippingAddress.SetShippingAddress();

                SwitchPanelByState(CheckoutPageState.ShippingOptions);
                uxCheckoutShippingOption.PopulateControls();
                if (isRestoredShippingOption == false)
                {
                    uxCheckoutShippingOption.RestoreSelectedShippingOption();
                    isRestoredShippingOption = true;
                }
            }
        }
        else if (CurrentState == CheckoutPageState.ShippingOptions)
        {
            uxCheckoutShippingAddress.SetBillingAddressAnonymous();
            if (Request.QueryString["Token"] != null)
            {
                PayPalProExpressPaymentMethod payment = ( PayPalProExpressPaymentMethod )
                                                        StoreContext.CheckoutDetails.PaymentMethod;

                if (!payment.ProcessPostLoginDetails(Request.QueryString["Token"], StoreContext.CheckoutDetails))
                {
                    CheckoutNotCompletePage.RedirectToPage(
                        "Error Message",
                        payment.GetErrorMessage(),
                        "ShoppingCart.aspx",
                        "Return To Shopping");
                }
            }

            if (uxCheckoutShippingOption.ShippingOptionList.Items.Count <= 0)
            {
                uxShippingOptionNextImageButton.Visible = false;
                uxCheckoutShippingOption.DisplayNoShippingOption();
            }

            if ((StoreContext.ShoppingCart.GetCartItems().Length > 0 &&
                 !StoreContext.ShoppingCart.ContainsShippableItem()) ||
                !DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode"))
            {
                StoreContext.CheckoutDetails.SetShipping(ShippingMethod.Null);

                SwitchPanelByState(CheckoutPageState.PaymentMethods);
                uxCheckoutPaymentMethods.PopulateControls();
                if (isRestoredShippingMethod == false)
                {
                    uxCheckoutPaymentMethods.RestorePaymentMethod();
                    isRestoredShippingMethod = true;
                }
            }
        }
        else if (CurrentState == CheckoutPageState.PaymentMethods)
        {
            PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                StoreContext.Culture, StoreContext.CheckoutDetails.PaymentMethod.Name);

            if (!StoreContext.ShoppingCart.ContainsRecurringProduct())
            {
                if (!paymentOption.PaymentMethodSelectionAllowed)
                {
                    if (!(Request.QueryString["skiplogin"] == "true"))
                    {
                        Response.Redirect("OrderSummary.aspx");
                    }
                    else
                    {
                        Response.Redirect("OrderSummary.aspx?skiplogin=true");
                    }
                }

                if (StoreContext.GetOrderAmount().Total <= 0)
                {
                    string paymentMethodName = PaymentOption.NoPaymentName;
                    string secondaryName     = String.Empty;

                    if (HasCoupon() || HasGiftCertificate())
                    {
                        if (HasCoupon())
                        {
                            secondaryName += "Coupon";
                        }

                        if (HasGiftCertificate())
                        {
                            if (HasCoupon())
                            {
                                secondaryName += " / ";
                            }

                            secondaryName += "Gift Certificate";
                        }
                    }
                    PaymentOption zeroPaymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                        StoreContext.Culture, paymentMethodName);
                    PaymentMethod paymentMethod = zeroPaymentOption.CreatePaymentMethod();
                    paymentMethod.SecondaryName = secondaryName;
                    StoreContext.CheckoutDetails.SetPaymentMethod(paymentMethod);

                    if (!(Request.QueryString["skiplogin"] == "true"))
                    {
                        Response.Redirect("OrderSummary.aspx");
                    }
                    else
                    {
                        Response.Redirect("OrderSummary.aspx?skiplogin=true");
                    }
                }
            }


            if (StoreContext.ShoppingCart.ContainsRecurringProduct())
            {
                if (uxCheckoutPaymentMethods.PaymentList.Items.Count > 1)
                {
                    uxCheckoutPaymentMethods.DisplayError("[$RecurringPaymentError]");
                }
            }
        }
        else if (CurrentState == CheckoutPageState.PaymentInfo)
        {
            PaymentMethod paymentMethod = StoreContext.CheckoutDetails.PaymentMethod;
            PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(StoreContext.Culture, paymentMethod.Name);

            if (!paymentOption.CreditCardRequired)
            {
                uxCheckoutPaymentInfo.SetCheckoutBillingAddress();

                if (!IsAnonymousCheckout())
                {
                    Response.Redirect("OrderSummary.aspx");
                }
                else
                {
                    Response.Redirect("OrderSummary.aspx?skiplogin=true");
                }
            }
        }
    }
Ejemplo n.º 19
0
    private void PopulateControls()
    {
        decimal shippingTax   = 0;
        decimal handlingTax   = 0;
        bool    isTaxIncluded = DataAccessContext.Configurations.GetBoolValue("TaxIncludedInPrice");

        if (StoreContext.ShoppingCart.GetCartItems().Length > 0)
        {
            uxPanel.Visible = true;

            OrderAmount orderAmount = StoreContext.GetOrderAmount();

            if (orderAmount.ShippingCost > 0)
            {
                if (!DataAccessContext.Configurations.GetBoolValue("IsTaxableShippingCost"))
                {
                    shippingTax = 0;
                }
                else
                {
                    shippingTax = orderAmount.ShippingCost * DataAccessContext.Configurations.GetDecimalValue("TaxPercentageIncludedInPrice") / 100;
                }
            }

            if (orderAmount.HandlingFee > 0)
            {
                if (!DataAccessContext.Configurations.GetBoolValue("IsTaxableShippingCost"))
                {
                    handlingTax = 0;
                }
                else
                {
                    handlingTax = orderAmount.HandlingFee * DataAccessContext.Configurations.GetDecimalValue("TaxPercentageIncludedInPrice") / 100;
                }
            }

            if (isTaxIncluded)
            {
                uxTotalAmountLabel.Text = StoreContext.Currency.FormatPrice(StoreContext.ShoppingCart.GetSubtotalIncludedTax(StoreContext.WholesaleStatus)
                                                                            + (orderAmount.ShippingCost + shippingTax)
                                                                            + (orderAmount.HandlingFee + handlingTax)
                                                                            + (orderAmount.Discount * -1)
                                                                            + (orderAmount.PointDiscount * -1)
                                                                            + (orderAmount.GiftCertificate * -1));
            }
            else
            {
                uxTotalAmountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Total);
            }

            if (isTaxIncluded)
            {
                uxSubTotalLabel.Text = StoreContext.Currency.FormatPrice(StoreContext.ShoppingCart.GetSubtotalIncludedTax(StoreContext.WholesaleStatus));
            }
            else
            {
                uxSubTotalLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Subtotal);
            }

            if (orderAmount.Discount > 0)
            {
                uxDiscountTR.Visible       = true;
                uxDiscountAmountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Discount * -1);
            }
            else
            {
                uxDiscountTR.Visible = false;
            }

            if (orderAmount.PointDiscount > 0)
            {
                uxRewardDiscountTR.Visible = true;
                uxRewardDiscountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.PointDiscount * -1);
            }
            else
            {
                uxRewardDiscountTR.Visible = false;
            }

            if (orderAmount.GiftCertificate > 0)
            {
                uxGiftDiscountTR.Visible = true;
                uxGiftDiscountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.GiftCertificate * -1);
            }
            else
            {
                uxGiftDiscountTR.Visible = false;
            }

            if (orderAmount.Tax > 0 && !isTaxIncluded)
            {
                uxTaxTR.Visible       = true;
                uxTaxAmountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.Tax);
            }
            else
            {
                uxTaxTR.Visible = false;
            }

            if (orderAmount.ShippingCost > 0)
            {
                uxShippingTR.Visible = true;
                if (isTaxIncluded)
                {
                    uxShippingAmountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.ShippingCost + shippingTax);
                }
                else
                {
                    uxShippingAmountLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.ShippingCost);
                }
            }
            else
            {
                uxShippingTR.Visible = false;
            }

            if (orderAmount.HandlingFee > 0)
            {
                uxHandlingFeeTR.Visible = true;
                if (isTaxIncluded)
                {
                    uxHandlingFeeLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.HandlingFee + handlingTax);
                }
                else
                {
                    uxHandlingFeeLabel.Text = StoreContext.Currency.FormatPrice(orderAmount.HandlingFee);
                }
            }
            else
            {
                uxHandlingFeeTR.Visible = false;
            }

            uxGrid.DataSource = StoreContext.ShoppingCart.GetCartItems();
            uxGrid.DataBind();
        }
        else
        {
            uxPanel.Visible        = false;
            uxCartEmptyDiv.Visible = true;
            uxCartEmptyLabel.Text  = "[$Your shopping cart is empty]";

            uxBackHomeLink.Visible = true;
            StoreContext.CheckoutDetails.Clear();
        }
        if (uxTaxIncludePanel.Visible)
        {
            uxTaxIncludeMessageLabel.Text =
                String.Format("[$TaxIncludeMessage1] {0} [$TaxIncludeMessage2]",
                              DataAccessContext.Configurations.GetValue("TaxPercentageIncludedInPrice").ToString());
        }

        PopulateContinueUrl();
        PopulateAddToGiftRegistryButton();
    }
Ejemplo n.º 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterStoreEvents();

        ICartItem[] cart = StoreContext.ShoppingCart.GetCartItems();
        if (cart.Length == 0)
        {
            Response.Redirect("Default.aspx");
        }

        PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
            StoreContext.Culture, StoreContext.CheckoutDetails.PaymentMethod.Name);

        if (!StoreContext.ShoppingCart.ContainsRecurringProduct())
        {
            if (!paymentOption.PaymentMethodSelectionAllowed)
            {
                if (!(Request.QueryString["skiplogin"] == "true"))
                {
                    Response.Redirect("OrderSummary.aspx");
                }
                else
                {
                    Response.Redirect("OrderSummary.aspx?skiplogin=true");
                }
            }

            if (StoreContext.GetOrderAmount().Total <= 0)
            {
                string paymentMethodName = PaymentOption.NoPaymentName;
                string secondaryName     = String.Empty;

                if (HasCoupon() || HasGiftCertificate())
                {
                    if (HasCoupon())
                    {
                        secondaryName += "Coupon";
                    }

                    if (HasGiftCertificate())
                    {
                        if (HasCoupon())
                        {
                            secondaryName += " / ";
                        }

                        secondaryName += "Gift Certificate";
                    }
                }
                PaymentOption zeroPaymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                    StoreContext.Culture, paymentMethodName);
                PaymentMethod paymentMethod = zeroPaymentOption.CreatePaymentMethod();
                paymentMethod.SecondaryName = secondaryName;
                StoreContext.CheckoutDetails.SetPaymentMethod(paymentMethod);

                if (!(Request.QueryString["skiplogin"] == "true"))
                {
                    Response.Redirect("OrderSummary.aspx");
                }
                else
                {
                    Response.Redirect("OrderSummary.aspx?skiplogin=true");
                }
            }

            this.ClientScript.RegisterClientScriptInclude("JSControls", "ClientScripts/controls.js");
        }

        if (!IsPostBack)
        {
            uxPaymentMehods.PopulateControls();
        }
    }