Esempio n. 1
0
    private bool SetPaymentAndRedirect()
    {
        if (!uxPaymentMehods.IsAnyPaymentSelected())
        {
            uxPaymentMehods.DisplayError("[$ErrorNoPaymentSelected]");
            return(false);
        }
        else if (uxPaymentMehods.IsPolicyAgreementEnabled() && !uxPaymentMehods.IsAgreeChecked())
        {
            uxPaymentMehods.DisplayPolicyAgreementError("[$ErrorNotCheckPolicyAgreement]");
            return(false);
        }

        string        paymentMethodName = uxPaymentMehods.GetSelectedPaymentName();
        PaymentOption paymentOption     = DataAccessContext.PaymentOptionRepository.GetOne(
            StoreContext.Culture, paymentMethodName);

        PaymentMethod paymentMethod = paymentOption.CreatePaymentMethod();

        paymentMethod.SecondaryName = uxPaymentMehods.GetSecondaryPaymentName();

        string poNumber = String.Empty;

        if (uxPaymentMehods.IsPONumberEmpty(out poNumber))
        {
            uxPaymentMehods.DisplayPOError("[$ErrorPONumberRequired]");
            return(false);
        }

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

        return(true);
    }
    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);
            }
        }
    }
    protected string ConvertPaymentMethod(string paymentMethodName)
    {
        PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
            StoreContext.Culture, PaymentOption.GetSimpleName(paymentMethodName));
        PaymentMethod paymentMethod = paymentOption.CreatePaymentMethod();

        if (paymentOption.ShownAsCreditCard)
        {
            return("Credit Card");
        }
        else
        {
            return(paymentMethodName);
        }
    }
    public PaymentMethod GetSelectedPaymentMethod()
    {
        string        paymentMethodName = GetSelectedPaymentName();
        PaymentOption paymentOption     = DataAccessContext.PaymentOptionRepository.GetOne(
            CurrentCulture, paymentMethodName);

        PaymentMethod paymentMethod = paymentOption.CreatePaymentMethod();

        paymentMethod.SecondaryName = GetSecondaryPaymentName();

        string poNumber = String.Empty;

        if (IsPONumberEmpty(out poNumber))
        {
            uxPaymentMethodMessageDiv.Visible = true;
            uxPaymentMethodMessageLabel.Text  = "[$ErrorPONumberRequired]";
        }

        paymentMethod.PONumber = poNumber;

        return(paymentMethod);
    }
Esempio n. 5
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();
        }
    }
Esempio n. 6
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");
                }
            }
        }
    }
    private void SetExpressCheckout()
    {
        string storefrontUrl = String.Empty;

        if (UrlManager.IsMobile())
        {
            storefrontUrl = UrlPath.StorefrontUrl + "Mobile/";
        }
        else
        {
            storefrontUrl = UrlPath.StorefrontUrl;
        }

        string returnURL = storefrontUrl + "Shipping.aspx";
        string cancelURL = storefrontUrl + "ShoppingCart.aspx";

        IList <decimal> discountLines;
        decimal         discount = GetDiscountLine(StoreContext.ShoppingCart.GetCartItems(), out discountLines);

        NVPCallerServices caller  = PayPalProExpressUtilities.Instance.PayPalAPIInitialize();
        NVPCodec          encoder = new NVPCodec();

        encoder["METHOD"]    = "SetExpressCheckout";
        encoder["AMT"]       = Vevo.Domain.Currency.ConvertPriceToUSFormat(GetShoppingCartTotal().ToString("f2"));
        encoder["RETURNURL"] = returnURL;
        encoder["CANCELURL"] = cancelURL;
        if (Request.QueryString["Token"] != null)
        {
            encoder["TOKEN"] = Request.QueryString["Token"];
        }
        encoder["PAYMENTACTION"] = PayPalProExpressUtilities.PaymentType;
        encoder["CURRENCYCODE"]  = DataAccessContext.Configurations.GetValue("PaymentCurrency");
        if (DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode"))
        {
            encoder["NOSHIPPING"] = "0";
        }
        else
        {
            encoder["NOSHIPPING"] = "1";
        }

        encoder["L_NAME0"] = "Payment for " + DataAccessContext.Configurations.GetValue(StoreContext.Culture.CultureID, "SiteName");
        encoder["L_AMT0"]  = Vevo.Domain.Currency.ConvertPriceToUSFormat(GetShoppingCartTotal().ToString("f2"));

        if (!UrlManager.IsMobile())
        {
            encoder["VERSION"] = "65.0";
        }

        string pStrrequestforNvp = encoder.Encode();
        string pStresponsenvp    = caller.Call(pStrrequestforNvp);

        NVPCodec decoder = new NVPCodec();

        decoder.Decode(pStresponsenvp);

        string strAck = decoder["ACK"];

        if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning"))
        {
            PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                StoreContext.Culture, PaymentOption.PayPalProExpress);
            StoreContext.CheckoutDetails.PaymentMethod = paymentOption.CreatePaymentMethod();
            //PayPalProExpressUtilities.Instance.Token = decoder["TOKEN"];
            StoreContext.CheckoutDetails.CustomParameters[CheckoutDetails.PayPalProExpress_TokenID] = decoder["TOKEN"];
            if (UrlManager.IsFacebook())
            {
                string script = "window.parent.location.href='" + PayPalProExpressUtilities.Instance.UrlSetExpressCheckout(UrlManager.IsMobile()) + "&useraction=commit&token=" + decoder["TOKEN"] + "'";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "startScript", script, true);
            }
            else
            {
                Response.Redirect(PayPalProExpressUtilities.Instance.UrlSetExpressCheckout(UrlManager.IsMobile()) + "&useraction=commit&token=" + decoder["TOKEN"]);
            }
        }
        else
        {
            //PayPalProExpressUtilities.RedirectToErrorPage( decoder );
            CheckoutNotCompletePage.RedirectToPage(
                "Error Message",
                PayPalProExpressUtilities.GetErrorMessage(decoder),
                "ShoppingCart.aspx",
                "Return To Shopping");
        }
    }
    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);
    }
    private void BuildShoppingCart(string requestXml, NewOrderNotification notification)
    {
        foreach (Item item in notification.shoppingcart.items)
        {
            XmlNode[] node = item.merchantprivateitemdata.Any;

            Product product = DataAccessContext.ProductRepository.GetOne(
                StoreContext.Culture,
                item.merchantitemid,
                new StoreRetriever().GetCurrentStoreID()
                );

            if (node.Length <= 1)
            {
                StoreContext.ShoppingCart.AddItem(
                    product, item.quantity);
            }
            else
            {
                // Creating option item from google checkout is not details of option type is text.
                OptionItemValueCollection optionCollection = OptionItemValueCollection.Null;
                if (!String.IsNullOrEmpty(node[1].InnerText))
                {
                    optionCollection = new OptionItemValueCollection(
                        StoreContext.Culture, node[1].InnerText, item.merchantitemid);
                }

                StoreContext.ShoppingCart.AddItem(
                    product, item.quantity, optionCollection);
            }
        }

        Log.Debug("SetShippingDetails");
        Vevo.Base.Domain.Address address = new Vevo.Base.Domain.Address(
            notification.buyershippingaddress.contactname,
            "",
            notification.buyerbillingaddress.companyname,
            notification.buyershippingaddress.address1,
            notification.buyershippingaddress.address2,
            notification.buyershippingaddress.city,
            notification.buyershippingaddress.region,
            notification.buyershippingaddress.postalcode,
            notification.buyershippingaddress.countrycode,
            notification.buyerbillingaddress.phone,
            notification.buyerbillingaddress.fax);

        StoreContext.CheckoutDetails.ShippingAddress = new ShippingAddress(address, false);

        Log.Debug("Set Shipping ");
        MerchantCalculatedShippingAdjustment shippingAdjust = (MerchantCalculatedShippingAdjustment)notification.orderadjustment.shipping.Item;

        string         shippingID = DataAccessContext.ShippingOptionRepository.GetIDFromName(shippingAdjust.shippingname);
        ShippingMethod shipping   = ShippingFactory.CreateShipping(shippingID);

        shipping.Name = shippingAdjust.shippingname;
        StoreContext.CheckoutDetails.SetShipping(shipping);
        StoreContext.CheckoutDetails.SetCustomerComments("");

        PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
            StoreContext.Culture, PaymentOption.GoogleCheckout);

        StoreContext.CheckoutDetails.SetPaymentMethod(
            paymentOption.CreatePaymentMethod());

        Log.Debug("Set Coupon ID");
        StoreContext.CheckoutDetails.SetCouponID(GetCouponCode(notification.orderadjustment.merchantcodes.Items));

        Log.Debug("Set Gift");
        string giftID = GetGiftCertificateCode(notification.orderadjustment.merchantcodes.Items);

        if (giftID != String.Empty)
        {
            StoreContext.CheckoutDetails.SetGiftCertificate(giftID);
        }

        StoreContext.CheckoutDetails.SetGiftRegistryID("0");
        StoreContext.CheckoutDetails.SetShowShippingAddress(true);
    }