예제 #1
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);
    }
예제 #2
0
    private OrderNotifyService CreateOrder(CheckoutDetails checkout)
    {
        OrderCreateService orderCreateService = new OrderCreateService(
            StoreContext.ShoppingCart,
            checkout,
            StoreContext.Culture,
            CurrenntCurrency,
            AffiliateHelper.GetAffiliateCode(),
            WebUtilities.GetVisitorIP());

        OrderNotifyService orderBusiness;
        OrderAmount        amount = orderCreateService.GetOrderAmount(StoreContext.Customer)
                                    .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                             checkout,
                                             StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                             StoreContext.Customer));

        Order order = orderCreateService.PlaceOrder(amount,
                                                    StoreContext.Customer, DataAccessContext.StoreRetriever, StoreContext.Culture);

        GiftRegistry.UpdateGiftRegistryQuantity(StoreContext.ShoppingCart, checkout);
        CustomerRewardPoint.UpdateRedeemPoint(checkout, StoreContext.Customer, order);

        orderBusiness = new OrderNotifyService(order.OrderID);

        return(orderBusiness);
    }
예제 #3
0
        public string GetShippingCost(bool useProductShippingCost, string productID, string shippingID, object price)
        {
            decimal shippingCost = 0;
            decimal handlingFee  = 0;
            Product product      = DataAccessContext.ProductRepository.GetOne(
                AdminConfig.CurrentCulture, productID, new StoreRetriever().GetCurrentStoreID());

            CartItem      cartItem      = new CartItem(Cart.Null.CartID, product, 1);
            CartItemGroup cartItemGroup = new CartItemGroup(cartItem);

            ShippingOption shippingOption = DataAccessContext.ShippingOptionRepository.GetOne(
                AdminConfig.CurrentCulture, shippingID);

            if (!shippingOption.IsNull)
            {
                ShippingMethod shippingMethod = shippingOption.CreateNonRealTimeShippingMethod();

                shippingCost = shippingMethod.GetShippingCost(cartItemGroup, WholesaleStatus.Null, 0)
                               + CartItemPromotion.GetShippingCostFromPromotion(shippingMethod,
                                                                                cartItemGroup,
                                                                                WholesaleStatus.Null,
                                                                                0);
                handlingFee = shippingMethod.GetHandlingFee(cartItemGroup, WholesaleStatus.Null);
            }
            return(FormatNumber(shippingCost + handlingFee));
        }
예제 #4
0
    protected string GetItemImage(object cartItem)
    {
        ICartItem baseCartItem = ( ICartItem )cartItem;

        if (baseCartItem.IsPromotion)
        {
            CartItemPromotion cartItemPromotion = (CartItemPromotion)baseCartItem;
            PromotionGroup    promotion         = cartItemPromotion.PromotionSelected.GetPromotionGroup();

            if (String.IsNullOrEmpty(promotion.ImageFile))
            {
                return("~/Images/Products/Thumbnail/DefaultNoImage.gif");
            }
            else
            {
                return("~/" + promotion.ImageFile);
            }
        }
        else
        {
            ProductImage details = baseCartItem.Product.GetPrimaryProductImage();

            if (String.IsNullOrEmpty(details.ThumbnailImage))
            {
                return("~/Images/Products/Thumbnail/DefaultNoImage.gif");
            }
            else
            {
                return("~/" + details.ThumbnailImage);
            }
        }
    }
예제 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ProductID != "0")
     {
         Product             product          = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreContext.CurrentStore.StoreID);
         ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);
         if (subscriptionItem.IsSubscriptionProduct())
         {
             uxInvalidSubscriptionPanel.Visible = true;
         }
         else
         {
             uxInvalidSubscriptionPanel.Visible = false;
             if (StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart))
             {
                 uxProductFreeShippingCostPanel.Visible    = true;
                 uxProductNonFreeShippingCostPanel.Visible = false;
             }
             else
             {
                 uxProductNonFreeShippingCostPanel.Visible = true;
                 uxProductFreeShippingCostPanel.Visible    = false;
             }
         }
     }
     else
     {
         uxProductNonFreeShippingCostPanel.Visible = false;
         uxProductFreeShippingCostPanel.Visible    = false;
     }
 }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        uxContinueLink.NavigateUrl =
            "GiftRegistryItem.aspx?GiftRegistryID=" + StoreContext.CheckoutDetails.GiftRegistryID;

        uxContinueLink.Visible           = false;
        giftRegistryMessagePanel.Visible = false;
        if (ProductID != "0")
        {
            Product             product          = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreContext.CurrentStore.StoreID);
            ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);
            if (subscriptionItem.IsSubscriptionProduct())
            {
                uxMessage.DisplayError("Cannot add product to the cart.<br/><br/>You already have higher product subscription level.");
            }
            else
            {
                if (StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart))
                {
                    uxMessage.DisplayError("Cannot add product to the cart.<br/><br/>The shopping cart already has one or more product " +
                                           "that is a free shipping product.");
                    uxProductNonFreeShippingCostPanel.Visible = false;
                }
                else
                {
                    uxMessage.DisplayError("Cannot add product to the cart.<br/><br/>The shopping cart already has one or more product " +
                                           "that is not a free shipping.");
                    uxProductFreeShippingCostPanel.Visible = false;
                }
            }
        }
        else
        {
            if (FreeShipping != "0")
            {
                if (StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart))
                {
                    uxProductFreeShippingCostPanel.Visible    = true;
                    uxProductNonFreeShippingCostPanel.Visible = false;
                }
                else
                {
                    uxProductNonFreeShippingCostPanel.Visible = true;
                    uxProductFreeShippingCostPanel.Visible    = false;
                }
            }
            else if (PromotionStock != "0")
            {
                uxMessage.DisplayError("Cannot add Promotional product to the cart because it is out of stock.");
            }
            else
            {
                uxContinueLink.Visible           = true;
                giftRegistryMessagePanel.Visible = true;
                uxMessage.DisplayError("Failed adding product to the cart.<br/><br/>The shopping cart already has one or more gift registry item(s).<br/><br/>" +
                                       "Please add more items using gift registry item list menu.");
            }
        }
    }
예제 #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);
        }
    }
예제 #8
0
    private void PopulateRealTimeShipping(
        ListItemCollection radioItems,
        out string errorMessage,
        out string restriction)
    {
        uxRecurringWarringLabel.Text = "";
        IList <ShippingOption> realTimeShippingOptions = DataAccessContext.ShippingOptionRepository.GetShipping(
            CurrentCulture, BoolFilter.ShowTrue);

        errorMessage = String.Empty;
        restriction  = String.Empty;

        foreach (ShippingOption shippingOption in realTimeShippingOptions)
        {
            string tempError, tempRestriction;

            IList <ShippingChoice> shippingChoices = shippingOption.RequestRealTimeShippingChoices(
                StoreContext.CheckoutDetails.ShippingAddress,
                StoreContext.ShoppingCart,
                StoreContext.ShoppingCart.GetSubtotal(StoreContext.WholesaleStatus),
                StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart),
                StoreContext.CheckoutDetails.Coupon,
                out tempError,
                out tempRestriction);

            if (!String.IsNullOrEmpty(tempError))
            {
                errorMessage += shippingOption.ShippingOptionType.DisplayName + " Error: "
                                + tempError + "<br/><br/>";
            }

            if (!String.IsNullOrEmpty(tempRestriction))
            {
                restriction += "<strong>" + shippingOption.ShippingOptionType.DisplayName
                               + " Restrictions:</strong> " + tempRestriction + "<br/><br/>";
            }

            foreach (ShippingChoice shippingChoice in shippingChoices)
            {
                string text, value;

                FormatForListItem(
                    shippingOption.ShippingID,
                    shippingChoice.Name,
                    shippingChoice.ShippingCost,
                    shippingChoice.HandlingFee,
                    out text,
                    out value);

                radioItems.Add(new ListItem(text, value));
            }
        }
    }
예제 #9
0
    protected string GetLink(object cartItem)
    {
        ICartItem baseCartItem = ( ICartItem )cartItem;

        if (baseCartItem.IsPromotion)
        {
            CartItemPromotion cartItemPromotion = (CartItemPromotion)baseCartItem;
            PromotionGroup    promotion         = cartItemPromotion.PromotionSelected.GetPromotionGroup();
            return(UrlManager.GetPromotionUrl(promotion.PromotionGroupID, promotion.Locales[StoreContext.Culture].UrlName));
        }
        else
        {
            Product product = baseCartItem.Product;
            return(UrlManager.GetProductUrl(product.ProductID, product.Locales[StoreContext.Culture].UrlName));
        }
    }
    private void PopulateRealTimeShipping(
        ListItemCollection radioItems,
        out string errorMessage,
        out string restriction)
    {
        IList <ShippingOption> realTimeShippingOptions = DataAccessContext.ShippingOptionRepository.GetShipping(
            StoreContext.Culture, BoolFilter.ShowTrue);

        errorMessage = String.Empty;
        restriction  = String.Empty;

        foreach (ShippingOption shippingOption in realTimeShippingOptions)
        {
            string tempError, tempRestriction;

            IList <ShippingChoice> shippingChoices = shippingOption.RequestRealTimeShippingChoices(
                _shippingAddress,
                StoreContext.ShoppingCart,
                StoreContext.ShoppingCart.GetSubtotal(StoreContext.WholesaleStatus),
                StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart),
                StoreContext.CheckoutDetails.Coupon,
                out tempError,
                out tempRestriction);

            foreach (ShippingChoice shippingChoice in shippingChoices)
            {
                string text, value;

                FormatForListItem(
                    shippingOption.ShippingID,
                    shippingChoice.Name,
                    shippingChoice.ShippingCost,
                    shippingChoice.HandlingFee,
                    out text,
                    out value);

                radioItems.Add(new ListItem(text, value));
            }
        }
    }
예제 #11
0
    private decimal GetTotalWithoutRecurring(CheckoutDetails checkout)
    {
        OrderCalculator orderCalculator = new OrderCalculator();

        IList <CartItemGroup> cartItemGroups = StoreContext.ShoppingCart.SeparateCartItemGroups();

        decimal total = 0;

        foreach (CartItemGroup cartItemGroup in cartItemGroups)
        {
            if (!cartItemGroup.IsRecurring)
            {
                total += orderCalculator.Calculate(
                    checkout, cartItemGroup, StoreContext.Customer, 0)
                         .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                  checkout,
                                  cartItemGroup,
                                  StoreContext.Customer)).Total;
            }
        }

        return(total);
    }
예제 #12
0
    private bool IsEnoughStock(out string message)
    {
        message = String.Empty;

        foreach (ICartItem item in StoreContext.ShoppingCart.GetCartItems())
        {
            if (!item.IsPromotion)
            {
                int productStock = item.Product.GetStock(item.Options.GetUseStockOptionItemIDs());
                int currentStock = productStock - item.Quantity;

                if (currentStock != DataAccessContext.Configurations.GetIntValue("OutOfStockValue"))
                {
                    if (CatalogUtilities.IsOutOfStock(currentStock, CheckUseInventory(item.ProductID)))
                    {
                        message += "<li>" + item.GetName(StoreContext.Culture, StoreContext.Currency);
                        if (DataAccessContext.Configurations.GetBoolValue("ShowQuantity"))
                        {
                            int displayStock = productStock - DataAccessContext.Configurations.GetIntValue("OutOfStockValue");
                            if (displayStock < 0)
                            {
                                displayStock = 0;
                            }

                            message += " ( available " + displayStock + " items )";
                        }
                        else
                        {
                            message += "</li>";
                        }
                    }
                }
            }
            else
            {
                CartItemPromotion cartItemPromotion = (CartItemPromotion)item;
                PromotionSelected promotionSelected = cartItemPromotion.PromotionSelected;
                foreach (PromotionSelectedItem selectedItem in promotionSelected.PromotionSelectedItems)
                {
                    Product  product         = selectedItem.Product;
                    string[] optionsUseStock = selectedItem.GetUseStockOptionItems().ToArray(typeof(string)) as string[];
                    int      productStock    = product.GetStock(optionsUseStock);
                    int      currentStock    = productStock - item.Quantity;
                    if (currentStock != DataAccessContext.Configurations.GetIntValue("OutOfStockValue"))
                    {
                        if (CatalogUtilities.IsOutOfStock(currentStock, CheckUseInventory(product.ProductID)))
                        {
                            message += "<li>" + item.GetName(StoreContext.Culture, StoreContext.Currency);
                            message += "</li>";
                        }
                    }
                }
            }
        }

        if (!String.IsNullOrEmpty(message))
        {
            message =
                "<p class=\"ErrorHeader\">[$StockError]</p>" +
                "<ul class=\"ErrorBody\">" + message + "</ul>";

            return(false);
        }
        else
        {
            return(true);
        }
    }
예제 #13
0
    private bool IsEnoughStock(out string message)
    {
        message = String.Empty;

        int rowIndex;

        for (rowIndex = 0; rowIndex < uxGrid.Rows.Count; rowIndex++)
        {
            GridViewRow row = uxGrid.Rows[rowIndex];
            if (row.RowType == DataControlRowType.DataRow)
            {
                ICartItem cartItem    = (ICartItem)StoreContext.ShoppingCart.FindCartItemByID((string)uxGrid.DataKeys[rowIndex]["CartItemID"]);
                bool      isPromotion = (bool)uxGrid.DataKeys[rowIndex]["IsPromotion"];
                string    productID   = uxGrid.DataKeys[rowIndex]["ProductID"].ToString();
                string    productName = ((Label)row.FindControl("uxNameLabel")).Text;
                int       quantity    = ConvertUtilities.ToInt32(((TextBox)row.FindControl("uxQuantityText")).Text);
                if (!isPromotion)
                {
                    Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, productID, new StoreRetriever().GetCurrentStoreID());

                    OptionItemValueCollection options = (OptionItemValueCollection)uxGrid.DataKeys[rowIndex]["Options"];
                    int productStock = product.GetStock(options.GetUseStockOptionItemIDs());
                    int currentStock = productStock - quantity;
                    if (currentStock != DataAccessContext.Configurations.GetIntValue("OutOfStockValue"))
                    {
                        if (CatalogUtilities.IsOutOfStock(currentStock, CheckUseInventory(productID)))
                        {
                            message += "<li>" + productName;
                            if (DataAccessContext.Configurations.GetBoolValue("ShowQuantity"))
                            {
                                int displayStock = productStock - DataAccessContext.Configurations.GetIntValue("OutOfStockValue");
                                if (displayStock < 0)
                                {
                                    displayStock = 0;
                                }
                                message += " ( available " + displayStock + " items )";
                            }
                            else
                            {
                                message += "</li>";
                            }
                        }
                    }
                }
                else
                {
                    CartItemPromotion cartItemPromotion = (CartItemPromotion)cartItem;
                    PromotionSelected promotionSelected = cartItemPromotion.PromotionSelected;
                    foreach (PromotionSelectedItem item in promotionSelected.PromotionSelectedItems)
                    {
                        Product  product         = item.Product;
                        string[] optionsUseStock = item.GetUseStockOptionItems().ToArray(typeof(string)) as string[];
                        int      productStock    = product.GetStock(optionsUseStock);
                        int      currentStock    = productStock - quantity;
                        if (currentStock != DataAccessContext.Configurations.GetIntValue("OutOfStockValue"))
                        {
                            if (CatalogUtilities.IsOutOfStock(currentStock, CheckUseInventory(product.ProductID)))
                            {
                                message += "<li>" + productName;
                                message += "</li>";
                            }
                        }
                    }
                }
            }
        }

        if (!String.IsNullOrEmpty(message))
        {
            message =
                "<p class=\"ErrorHeader\">[$StockError]</p>" +
                "<ul class=\"ErrorBody\">" + message + "</ul>";

            return(false);
        }
        else
        {
            return(true);
        }
    }
예제 #14
0
    protected void uxAddToCartButton_Click(object sender, EventArgs e)
    {
        PromotionSelected promotion = new PromotionSelected(StoreContext.Culture, new StoreRetriever().GetCurrentStoreID());

        promotion.SetPromotionGroupID = PromotionGroupID;
        bool isSuccess = true;

        foreach (DataListItem item in uxList.Items)
        {
            if (item.FindControl("uxGroup") != null)
            {
                Components_PromotionProductGroup group = (Components_PromotionProductGroup)item.FindControl("uxGroup");
                if (group.IsSelectedProduct)
                {
                    string   productGroup = group.GetSelectedOption;
                    string[] groupInfo    = productGroup.Split(':');

                    IList <string> options = new List <string>();
                    foreach (string option in groupInfo[1].Split(','))
                    {
                        if (option.Trim() == "")
                        {
                            continue;
                        }
                        options.Add(option);
                    }
                    Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, groupInfo[0], new StoreRetriever().GetCurrentStoreID());
                    promotion.AddSelectedPromotionItem(group.PromotionSubGroupID, product, options);
                }
                else
                {
                    isSuccess = false;
                }
            }
        }
        if (!isSuccess)
        {
            return;
        }

        // Check Inventory
        isSuccess = CheckOutOfStock(promotion.PromotionSelectedItems);
        if (!isSuccess)
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=0&PromotionStock=1");
        }
        // Check Free Shipping
        isSuccess = CartItemPromotion.CheckCanAddItemToCart(StoreContext.ShoppingCart, promotion);
        if (isSuccess)
        {
            PromotionSelected.AddPromotionItem(StoreContext.ShoppingCart, promotion, 1);

            bool enableNotification = ConvertUtilities.ToBoolean(DataAccessContext.Configurations.GetValue("EnableAddToCartNotification", StoreContext.CurrentStore));
            if (UrlManager.IsMobileDevice(Request))
            {
                enableNotification = false;
            }
            if (enableNotification)
            {
                uxAddToCartNotification.Show(promotion, 1);
            }
            else
            {
                Response.Redirect("ShoppingCart.aspx");
            }
        }
        else
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=0&FreeShiping=1");
        }
    }
예제 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Extract the XML from the request.
        Stream       RequestStream       = Request.InputStream;
        StreamReader RequestStreamReader = new StreamReader(RequestStream);
        string       RequestXml          = RequestStreamReader.ReadToEnd();

        RequestStream.Close();
        Log.Debug("Request XML:\n" + RequestXml);

        string             gatewayOrderID = "";
        string             orderID;
        OrderNotifyService orderBusiness;

        try
        {
            // Act on the XML.
            switch (EncodeHelper.GetTopElement(RequestXml))
            {
            case "new-order-notification":
                Log.Debug("Start new-order-notification");
                NewOrderNotification N1 =
                    (NewOrderNotification)EncodeHelper.Deserialize(RequestXml,
                                                                   typeof(NewOrderNotification));
                string OrderNumber1 = N1.googleordernumber;

                PaymentLogUpdateNewOrderNotification(N1);
                _serialNumber = N1.serialnumber;
                Log.Debug("-********************- Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-");
                Log.Debug("GetOrderIDByGateWayID ( "
                          + OrderNumber1 + " ) = " + DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1));
                Log.Debug("-********************- END Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-");
                if (DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1) == "0")
                {
                    BuildShoppingCart(RequestXml, N1);

                    Log.Debug("Start converting to order");

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

                    string storeID = EncodeHelper.GetElementValue(RequestXml, "StoreID");
                    DataAccessContext.SetStoreRetriever(new StoreRetriever(storeID));

                    OrderAmount orderAmount = orderCreateService.GetOrderAmount(Customer.Null)
                                              .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                                       StoreContext.CheckoutDetails,
                                                       StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                                       Customer.Null));

                    Order order = orderCreateService.PlaceOrderAnonymous(orderAmount,
                                                                         SystemConst.UnknownUser,
                                                                         CreateBuyerBillingAddress(N1),
                                                                         ConvertToString(N1.buyerbillingaddress.email), DataAccessContext.StoreRetriever, StoreContext.Culture);

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

                    orderBusiness = new OrderNotifyService(order.OrderID);

                    Log.Debug("End converting to order");

                    Log.Debug("Start sending order email");
                    orderBusiness.SendOrderEmail();
                    Log.Debug("End sending order email");

                    Order orderDetail = DataAccessContext.OrderRepository.GetOne(order.OrderID);
                    orderDetail.GatewayOrderID = OrderNumber1;
                    Log.Debug("OrderDetail.GatewayOrderID = " + OrderNumber1);
                    Log.Debug("Start Save Order Detail");
                    DataAccessContext.OrderRepository.Save(orderDetail);
                    Log.Debug("End Save Order Detail");

                    DataAccessContext.SetStoreRetriever(new StoreRetriever());
                }
                else
                {
                    Order orderDetail = DataAccessContext.OrderRepository.GetOne(
                        DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1));

                    Log.Debug("-**************************- start Check Error -**************************-");
                    Log.Debug("N1.googleOrderNumber = " + N1.googleordernumber);
                    Log.Debug("OrderNumber1 = " + OrderNumber1);
                    Log.Debug("N1.buyerbillingaddress.contactname = " + ConvertToString(N1.buyerbillingaddress.contactname));
                    Log.Debug("N1.buyerbillingaddress.address1 = " + ConvertToString(N1.buyerbillingaddress.address1));
                    Log.Debug("N1.buyerbillingaddress.city = " + ConvertToString(N1.buyerbillingaddress.city));
                    Log.Debug("N1.buyerbillingaddress.region = " + ConvertToString(N1.buyerbillingaddress.contactname));
                    Log.Debug("N1.buyerbillingaddress.postalcode = " + ConvertToString(N1.buyerbillingaddress.postalcode));
                    Log.Debug("orderDetail.Billing.Company = " + orderDetail.Billing.Company);
                    Log.Debug("orderDetail.Billing.Country = " + orderDetail.Billing.Country);
                    Log.Debug("orderDetail.Billing.Phone = " + orderDetail.Billing.Phone);
                    Log.Debug("orderDetail.Billing.Fax = " + orderDetail.Billing.Fax);
                    Log.Debug("-**************************- End Check Error -**************************-");

                    orderDetail.Billing = new Vevo.Base.Domain.Address(ConvertToString(N1.buyerbillingaddress.contactname),
                                                                       String.Empty, orderDetail.Billing.Company,
                                                                       ConvertToString(N1.buyerbillingaddress.address1),
                                                                       ConvertToString(N1.buyerbillingaddress.address2),
                                                                       ConvertToString(N1.buyerbillingaddress.city),
                                                                       ConvertToString(N1.buyerbillingaddress.region),
                                                                       ConvertToString(N1.buyerbillingaddress.postalcode),
                                                                       orderDetail.Billing.Country, orderDetail.Billing.Phone,
                                                                       orderDetail.Billing.Fax);
                    orderDetail.Email = ConvertToString(N1.buyerbillingaddress.email);

                    DataAccessContext.OrderRepository.Save(orderDetail);
                }

                Log.Debug("End new-order-notification");
                break;

            case "risk-information-notification":
                Log.Debug("risk-information-notification");
                RiskInformationNotification N2 = (RiskInformationNotification)EncodeHelper.Deserialize(
                    RequestXml, typeof(RiskInformationNotification));
                // This notification tells us that Google has authorized the order
                // and it has passed the fraud check.
                // Use the data below to determine if you want to accept the order, then start processing it.
                gatewayOrderID = N2.googleordernumber;
                _serialNumber  = N2.serialnumber;

                PaymentLogUpdateRiskInformation(N2);
                VerifyAvsAndCvv(N2);
                break;

            case "order-state-change-notification":
                Log.Debug("Start order-state-change-notification");
                OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize(
                    RequestXml, typeof(OrderStateChangeNotification));

                _serialNumber = N3.serialnumber;

                PaymentLogUpdateOrderStateChange(N3);

                if (N3.newfinancialorderstate != N3.previousfinancialorderstate)
                {
                    Order orderDetail = DataAccessContext.OrderRepository.GetOne(
                        DataAccessContext.OrderRepository.GetOrderIDByGatewayID(N3.googleordernumber));
                    orderDetail.GatewayPaymentStatus = N3.newfinancialorderstate.ToString();

                    DataAccessContext.OrderRepository.Save(orderDetail);

                    switch (N3.newfinancialorderstate)
                    {
                    case FinancialOrderState.PAYMENT_DECLINED:
                    case FinancialOrderState.CANCELLED_BY_GOOGLE:
                        SendErrorEmail(N3);
                        break;

                    case FinancialOrderState.CHARGEABLE:
                        if (DataAccessContext.Configurations.GetBoolValueNoThrow("GCheckoutChargeAuto"))
                        {
                            GoogleChargeOrder(N3.googleordernumber);
                        }
                        break;
                    }
                }

                Log.Debug("End order-state-change-notification");
                break;

            case "charge-amount-notification":
                Log.Debug("Start charge-amount-notification");
                ChargeAmountNotification N4 = (ChargeAmountNotification)EncodeHelper.Deserialize(RequestXml,
                                                                                                 typeof(ChargeAmountNotification));
                // Google has successfully charged the customer's credit card.
                gatewayOrderID = N4.googleordernumber;
                _serialNumber  = N4.serialnumber;

                PaymentLogChargeAmountUpdate(N4);

                orderID       = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID);
                orderBusiness = new OrderNotifyService(orderID);
                orderBusiness.ProcessPaymentComplete();
                Log.Debug("End charge-amount-notification");
                break;

            case "refund-amount-notification":
                Log.Debug("Start refund-amount-notification");

                RefundAmountNotification N5 =
                    (RefundAmountNotification)EncodeHelper.Deserialize(
                        RequestXml,
                        typeof(RefundAmountNotification));
                // Google has successfully refunded the customer's credit card.
                gatewayOrderID = N5.googleordernumber;
                _serialNumber  = N5.serialnumber;
                //decimal RefundedAmount = N5.latestrefundamount.Value;

                PaymentLogUpdateRefundAmount(N5);
                Order orderDetails = DataAccessContext.OrderRepository.GetOne(
                    DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID));
                orderDetails.PaymentComplete = false;
                DataAccessContext.OrderRepository.Save(orderDetails);

                Log.Debug("End refund-amount-notification");
                break;

            case "chargeback-amount-notification":
                Log.Debug("Start chargeback-amount-notification");

                ChargebackAmountNotification N6 = (ChargebackAmountNotification)EncodeHelper.Deserialize(
                    RequestXml, typeof(ChargebackAmountNotification));
                // A customer initiated a chargeback with his credit card company to get her money back.
                gatewayOrderID = N6.googleordernumber;
                _serialNumber  = N6.serialnumber;
                decimal ChargebackAmount = N6.latestchargebackamount.Value;

                PaymentLogUpdateChargeback(N6);

                orderDetails = DataAccessContext.OrderRepository.GetOne(
                    DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID));
                orderDetails.GatewayPaymentStatus = "ChargeBack";
                DataAccessContext.OrderRepository.Save(orderDetails);

                Log.Debug("End chargeback-amount-notification");
                break;

            default:
                break;
            }
        }
        catch (Exception ex)
        {
            DataAccessContext.SetStoreRetriever(new StoreRetriever());
            Log.Debug(ex.ToString());
        }
    }