Esempio n. 1
0
        public void OrderSystem_PaymentPlan_CreateFromOrder_FirstPurchaseOrder()
        {
            Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid());

            cart.OrderForms[0].Payments.Clear();
            cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment());
            cart.AcceptChanges();
            cart.RunWorkflow("CartValidate");
            cart.RunWorkflow("CartPrepare");
            cart.OrderForms[0].Payments[0].Amount = cart.Total;
            //cart.RunWorkflow("CartCheckout");
            cart.AcceptChanges();

            // Create payment plan
            PaymentPlan plan = cart.SaveAsPaymentPlan();

            // Set some payment plan values
            // Monthly subscription for a year
            plan.CycleMode           = PaymentPlanCycle.Months;
            plan.CycleLength         = 1;
            plan.MaxCyclesCount      = 12;
            plan.StartDate           = DateTime.UtcNow;
            plan.EndDate             = DateTime.UtcNow.AddMonths(13);
            plan.LastTransactionDate = DateTime.UtcNow;

            // Send emails
            OrderHelper.SendEmail(plan, "order-paymentplan-confirm");
            OrderHelper.SendEmail(plan, "order-paymentplan-notify");

            // Now create first PO from the payment plan
            PurchaseOrder po = plan.SaveAsPurchaseOrder();

            // Validate
            Assert.AreEqual(po.OrderForms[0].Payments.Count, 1);
        }
Esempio n. 2
0
        public void OrderSystem_UnitTest_Payments_GiftCardSucceed()
        {
            // Creating cart fails
            Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid());

            cart.OrderForms[0].Payments.Clear();
            cart.OrderForms[0].Payments.Add(OrderHelper.CreateGiftCardPayment());
            cart.AcceptChanges();
            cart.RunWorkflow("CartValidate");
            cart.RunWorkflow("CartPrepare");
            cart.OrderForms[0].Payments[0].Amount = cart.Total;
            cart.RunWorkflow("CartCheckout");
            cart.AcceptChanges();
            PurchaseOrder po = cart.SaveAsPurchaseOrder();

            po = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId);

            // Validate purchase order
            Assert.AreEqual(po.OrderForms[0].Payments.Count, 1);
            // Delete PO
            po.Delete();
            po.AcceptChanges();
            // Assert that PO is deleted
            Assert.IsTrue(po.ObjectState == MetaObjectState.Deleted);
            // Delete cart
            cart.Delete();
            cart.AcceptChanges();
            // Assert that cart is deleted
            Assert.IsTrue(cart.ObjectState == MetaObjectState.Deleted);
        }
        private void AddShipping(Cart c, OrderAddress shippingAddress)
        {
            foreach (Shipment ship in c.OrderForms[0].Shipments)
            {
                ship.Delete();
            }

            Shipment shipment = c.OrderForms[0].Shipments.AddNew();

            shipment.ShippingAddressId = shippingAddress.Name;

            for (int i = 0; i < c.OrderForms[0].LineItems.Count; i++)
            {
                LineItem item = c.OrderForms[0].LineItems[i];
                shipment.AddLineItemIndex(i, item.Quantity);
            }

            if (c.OrderForms[0].Shipments != null && c.OrderForms[0].Shipments.Count > 0)
            {
                shipment = c.OrderForms[0].Shipments[0];
                ShippingMethodAndRate selectedShippingMethod = GetSelectedShippingMethod();

                if (selectedShippingMethod != null)
                {
                    shipment.ShippingMethodId   = selectedShippingMethod.ShippingMethodId;
                    shipment.ShippingMethodName = selectedShippingMethod.ShippingMethodName;
                    c.AcceptChanges();
                }
            }

            c.AcceptChanges();
        }
Esempio n. 4
0
        /// <summary>
        /// Creates the payment plan.
        /// </summary>
        /// <returns></returns>
        public static Cart CreateCartForPaymentPlan()
        {
            Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid());

            cart.OrderForms[0].Payments.Clear();
            cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment());
            cart.OrderForms[0].Payments[0].BillingAddressId = cart.OrderForms[0].BillingAddressId;
            cart.AcceptChanges();
            cart.RunWorkflow("CartValidate");
            cart.RunWorkflow("CartPrepare");
            cart.OrderForms[0].Payments[0].Amount = cart.Total;
            cart.AcceptChanges();

            return(cart);
        }
    /// <summary>
    /// Creates a purchase order with the given order number and deletes the cart
    /// </summary>
    /// <param name="cart">Cart</param>
    /// <param name="payment">Payment</param>
    /// <param name="orderNumber">orderNumber</param>
    /// <returns>Boolean indicating success or failure</returns>
    private bool CreatePurchaseOrder(Cart cart, Payment payment, string orderNumber)
    {
        try
        {
            using (TransactionScope scope = new TransactionScope())
            {
                PaymentStatusManager.ProcessPayment(payment);

                cart.OrderNumberMethod = c => orderNumber;
                PurchaseOrder purchaseOrder = cart.SaveAsPurchaseOrder();

                cart.Delete();
                cart.AcceptChanges();

                purchaseOrder.AcceptChanges();
                scope.Complete();
            }
            return(true);
        }
        catch (Exception e)
        {
            // Add your own logging
            return(false);
        }
    }
Esempio n. 6
0
        /// <summary>
        /// Change shipping method
        /// </summary>
        protected void ChangeShippingMethod()
        {
            string shippingMethodId = string.Empty;

            foreach (ListViewDataItem item in shippingOptions.Items)
            {
                var rdo = item.FindControl("rdoChooseShipping") as GlobalRadioButton;
                if (rdo != null)
                {
                    if (rdo.Checked)
                    {
                        var hidden = item.FindControl("hiddenShippingId") as HtmlInputControl;
                        if (hidden != null)
                        {
                            shippingMethodId = hidden.Value;
                            break;
                        }
                    }
                }
            }

            Shipment.ShippingMethodId = new Guid(shippingMethodId);

            // restore coupon code to context
            string couponCode = Session[Constants.LastCouponCode] as string;

            if (!String.IsNullOrEmpty(couponCode))
            {
                MarketingContext.Current.AddCouponToMarketingContext(couponCode);
            }

            //Calculate shipping, disocunts, totals, etc
            OrderGroupWorkflowManager.RunWorkflow(Cart, OrderGroupWorkflowManager.CartPrepareWorkflowName);
            Cart.AcceptChanges();
        }
Esempio n. 7
0
        public void OrderSystem_GetPurchaseOrderTest()
        {
            Cart cart = CreateShoppingCart();

            cart.OrderForms[0].LineItems[0].Discounts.Add(OrderHelper.CreateLineItemDiscount());

            ShipmentDiscount discount = new ShipmentDiscount();

            discount.DiscountAmount = 10;
            discount.DiscountId     = 1;
            discount.DiscountName   = "asas";
            discount.DiscountValue  = 10;
            discount.DisplayMessage = "asdasd";


            ShipmentDiscount discount2 = new ShipmentDiscount();

            discount2.DiscountAmount = 10;
            discount2.DiscountId     = 2;
            discount2.DiscountName   = "asas";
            discount2.DiscountValue  = 10;
            discount2.DisplayMessage = "asdasd";


            cart.OrderForms[0].Shipments[0].Discounts.Add(discount);
            cart.OrderForms[0].Shipments[0].Discounts.Add(discount2);

            int cartLineItemDiscountCount = cart.OrderForms[0].LineItems[0].Discounts.Count;

            PurchaseOrder po = cart.SaveAsPurchaseOrder();

            po.AcceptChanges();

            // Reload cart from database
            PurchaseOrder po2 = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId);

            int po1ShipmentDiscountsCount = po.OrderForms[0].Shipments[0].Discounts.Count;
            int po2ShipmentDiscountsCount = po2.OrderForms[0].Shipments[0].Discounts.Count;
            int po2LineItemDiscountCount  = po2.OrderForms[0].LineItems[0].Discounts.Count;

            // Now remove discounts and add them again
            foreach (ShipmentDiscount dis in po2.OrderForms[0].Shipments[0].Discounts)
            {
                dis.Delete();
            }

            po2.OrderForms[0].Shipments[0].Discounts.Add(discount);
            po2.OrderForms[0].Shipments[0].Discounts.Add(discount2);
            po2.AcceptChanges();

            // Remove created stuff
            cart.Delete();
            cart.AcceptChanges();
            po2.Delete();
            po2.AcceptChanges();

            Assert.AreEqual(po1ShipmentDiscountsCount, po2ShipmentDiscountsCount);
            Assert.AreEqual(cartLineItemDiscountCount, po2LineItemDiscountCount);
        }
Esempio n. 8
0
        /// <summary>
        /// Adds the address.
        /// </summary>
        /// <param name="addressType">The address type.</param>
        private void AddOrderAddress(string addressType)
        {
            var orderAddress = _cartHelper.FindAddressByName(Name.Text);

            if (orderAddress == null)
            {
                orderAddress = new OrderAddress()
                {
                    ModifierId = SecurityContext.Current.CurrentUserId.ToString(),
                    Modified   = DateTime.Now.ToUniversalTime()
                };

                Cart.OrderAddresses.Add(orderAddress);
            }

            orderAddress.FirstName          = FirstName.Text;
            orderAddress.LastName           = LastName.Text;
            orderAddress.Email              = Email.Text;
            orderAddress.DaytimePhoneNumber = Phone.Text;
            orderAddress.Line1              = StreetAddress.Text;
            orderAddress.Line2              = Apartment.Text;
            orderAddress.City        = City.Text;
            orderAddress.State       = State.Text;
            orderAddress.PostalCode  = Zip.Text;
            orderAddress.Name        = Name.Text;
            orderAddress.CountryCode = Country.SelectedValue;

            if (addressType.Equals("billing"))
            {
                Cart.OrderForms[0].BillingAddressId = orderAddress.Name;
            }
            else
            {
                int shipId;
                if (int.TryParse(shipmentId.Value, out shipId))
                {
                    var shipment = Cart.OrderForms[0].Shipments.ToArray().First(s => s.Id == shipId);
                    shipment.ShippingAddressId = orderAddress.Name;
                }
                else
                {
                    var shipment = Cart.OrderForms[0].Shipments.ToArray().FirstOrDefault() ??
                                   new Shipment()
                    {
                        CreatorId = SecurityContext.Current.CurrentUserId.ToString(),
                        Created   = DateTime.UtcNow
                    };
                    shipment.ShippingAddressId = orderAddress.Name;

                    if (Cart.OrderForms[0].Shipments.Count < 1)
                    {
                        Cart.OrderForms[0].Shipments.Add(shipment);
                    }
                }
            }

            Cart.AcceptChanges();
        }
Esempio n. 9
0
        private bool IsValidSingleShippment()
        {
            // Check valid line item for Single Shipment
            if (Cart.OrderForms.Count > 0)
            {
                List <string> warehouseCodes = new List <string>();
                var           lineItems      = Cart.OrderForms[0].LineItems;
                foreach (LineItem lineItem in lineItems)
                {
                    if (!warehouseCodes.Contains(lineItem.WarehouseCode))
                    {
                        warehouseCodes.Add(lineItem.WarehouseCode);
                    }
                }

                // Cart only has one warehouse instore pickup
                if (warehouseCodes.Count == 1)
                {
                    // Shipping method is "In store pickup", add address to Cart & Shipment
                    IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCodes.FirstOrDefault());

                    if (!warehouse.IsFulfillmentCenter && warehouse.IsPickupLocation)
                    {
                        Shipment.WarehouseCode = warehouse.Code;

                        if (CartHelper.FindAddressByName(warehouse.Name) == null)
                        {
                            var address = warehouse.ContactInformation.ToOrderAddress();
                            address.Name = warehouse.Name;
                            Cart.OrderAddresses.Add(address);
                        }

                        Shipment.ShippingAddressId  = warehouse.Name;
                        Shipment.ShippingMethodName = ShippingManager.PickupShippingMethodName;

                        var instorepickupShippingMethod = ShippingManager.GetShippingMethods("en").ShippingMethod.ToArray().Where(m => m.Name.Equals(ShippingManager.PickupShippingMethodName)).FirstOrDefault();
                        if (instorepickupShippingMethod != null)
                        {
                            Shipment.ShippingMethodId = instorepickupShippingMethod.ShippingMethodId;
                        }

                        Cart.AcceptChanges();
                    }
                }
                else
                {
                    foreach (string warehouseCode in warehouseCodes)
                    {
                        IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCode);
                        if (warehouse != null && warehouse.IsPickupLocation)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 10
0
        // Merge annoymous cart with user cart after loggin.
        public void AppendToCart(Cart cartToAppend)
        {
            //merge
            _cartHelper.Cart.Add(cartToAppend, true);
            _cartHelper.Cart.AcceptChanges();

            //delete from anonymous cart
            cartToAppend.Delete();
            cartToAppend.AcceptChanges();
        }
Esempio n. 11
0
        public void OrderSystem_UnitTest_Payments_CashCardSucceed()
        {
            Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid());

            cart.OrderForms[0].Payments.Clear();
            cart.OrderForms[0].Payments.Add(OrderHelper.CreateCashCardPayment());
            cart.AcceptChanges();
            cart.RunWorkflow("CartValidate");
            cart.RunWorkflow("CartPrepare");
            cart.OrderForms[0].Payments[0].Amount = cart.Total;
            cart.RunWorkflow("CartCheckout");
            cart.AcceptChanges();
            PurchaseOrder po = cart.SaveAsPurchaseOrder();

            po = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId);

            // Validate
            Assert.AreEqual(po.OrderForms[0].Payments.Count, 1);
        }
Esempio n. 12
0
        public void OrderSystem_Payments_AuthorizeNET_CreateNew()
        {
            CreditCardPayment payment;
            string            cardType = "Visa";
            int expMonth = 4;
            int expYear  = DateTime.UtcNow.AddYears(5).Year;

            // Create cart
            Cart cart = OrderHelper.CreateCartForPaymentPlan();

            // Create payment plan
            PaymentPlan plan = cart.SaveAsPaymentPlan();

            // Set some payment plan values
            plan.CycleMode           = PaymentPlanCycle.Months;
            plan.CycleLength         = 1;
            plan.MaxCyclesCount      = 12;
            plan.StartDate           = DateTime.UtcNow;
            plan.EndDate             = DateTime.UtcNow.AddMonths(13);
            plan.LastTransactionDate = DateTime.UtcNow;

            //create cc payment to validate test account
            payment                  = (CreditCardPayment)plan.OrderForms[0].Payments[0];
            payment.CardType         = cardType;
            payment.CreditCardNumber = "4012888818888";
            payment.ExpirationMonth  = expMonth;
            payment.ExpirationYear   = expYear;

            // Execute workflow
            plan.RunWorkflow("CartCheckout");

            // Update last transaction date
            plan.LastTransactionDate = DateTime.UtcNow;
            // Encrease cycle count
            plan.CompletedCyclesCount++;

            // Save changes
            plan.AcceptChanges();

            plan = OrderContext.Current.GetPaymentPlan(plan.CustomerId, plan.OrderGroupId);

            // Validate payment plan
            Assert.IsTrue(!String.IsNullOrEmpty(plan.OrderForms[0].Payments[0].AuthorizationCode));
            // Delete payment plan
            plan.Delete();
            plan.AcceptChanges();
            // Assert that payment plan is deleted
            Assert.IsTrue(plan.ObjectState == MetaObjectState.Deleted);

            // Delete cart
            cart.Delete();
            cart.AcceptChanges();
            // Assert that cart is deleted
            Assert.IsTrue(cart.ObjectState == MetaObjectState.Deleted);
        }
Esempio n. 13
0
        public void OrderSystem_ShoppingCartMerge()
        {
            Cart cart = CreateShoppingCart();

            cart.AcceptChanges();
            Cart cart2 = CreateShoppingCart();

            cart2.AcceptChanges();

            int lineItemCount = 0;

            // Count number of items
            foreach (OrderForm form in cart.OrderForms)
            {
                lineItemCount += form.LineItems.Count;
            }

            // Perform merge
            cart.Add(cart2);
            cart.AcceptChanges();

            // Clean up
            cart2.Delete();
            cart2.AcceptChanges();

            // Reload the cart
            cart = OrderContext.Current.GetCart(cart.CustomerId, cart.OrderGroupId);

            int lineItemCount2 = 0;

            // Count number of items
            foreach (OrderForm form in cart.OrderForms)
            {
                lineItemCount2 += form.LineItems.Count;
            }

            // Number should be double
            Assert.AreEqual(lineItemCount * 2, lineItemCount2);

            cart.Delete();
            cart.AcceptChanges();
        }
Esempio n. 14
0
        public void OrderSystem_UnitTest_Payments_CreditCardSucceed()
        {
            Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid());

            cart.OrderForms[0].Payments.Clear();
            cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment());
            cart.AcceptChanges();
            cart.RunWorkflow("CartValidate");
            cart.RunWorkflow("CartPrepare");
            cart.OrderForms[0].Payments[0].Amount = cart.Total;
            // Following line throws exception:
            // "Authorize.NET payment gateway is not configured correctly. User is not set.."
            cart.RunWorkflow("CartCheckout");
            cart.AcceptChanges();
            PurchaseOrder po = cart.SaveAsPurchaseOrder();

            po = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId);

            // Validate
            Assert.AreEqual(po.OrderForms[0].Payments.Count, 1);
        }
Esempio n. 15
0
        public void OrderSystem_CreateCartTest()
        {
            Guid newCustomer = Guid.NewGuid();
            Cart cart        = OrderContext.Current.GetCart("myname", newCustomer);

            cart.CustomerName = "some name";
            cart.AcceptChanges();

            Cart newCart = OrderContext.Current.GetCart("myname", newCustomer);

            Assert.AreEqual(cart.CustomerName, newCart.CustomerName);
        }
Esempio n. 16
0
        public void OrderSystem_Notifications_CreditCard_CustomerEmail()
        {
            Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid());

            cart.OrderForms[0].Payments.Clear();
            cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment());
            cart.AcceptChanges();
            cart.RunWorkflow("CartValidate");
            cart.RunWorkflow("CartPrepare");
            //cart.RunWorkflow("CartCheckout");
            cart.AcceptChanges();
            PurchaseOrder po = cart.SaveAsPurchaseOrder();

            po = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId);

            // Send emails
            OrderHelper.SendEmail(po, "order-purchaseorder-confirm");
            OrderHelper.SendEmail(po, "order-purchaseorder-notify");

            // Validate
            Assert.AreEqual(po.OrderForms[0].Payments.Count, 1);
        }
Esempio n. 17
0
        /// <summary>
        /// Create split shipment for the first time.
        /// </summary>
        private void CreateDataSplitShipment()
        {
            // Create shipment for each lineitem for the first time to demo showcase multishipment.
            if (Cart.OrderForms.Count > 0)
            {
                var lineItems = Cart.OrderForms[0].LineItems;
                if (Cart.OrderForms[0].Shipments.Count != lineItems.Count)
                {
                    foreach (MetaObject shipment in Cart.OrderForms[0].Shipments)
                    {
                        shipment.Delete();
                    }

                    foreach (LineItem lineItem in lineItems)
                    {
                        Shipment shipment = new Shipment();
                        shipment.CreatorId = SecurityContext.Current.CurrentUserId.ToString();
                        shipment.Created   = DateTime.UtcNow;
                        shipment.AddLineItemIndex(lineItems.IndexOf(lineItem), lineItem.Quantity);
                        shipment.WarehouseCode = lineItem.WarehouseCode;

                        // For Shipping method "In store pickup"
                        IWarehouse warehouse = WarehouseHelper.GetWarehouse(lineItem.WarehouseCode);
                        if (!warehouse.IsFulfillmentCenter && warehouse.IsPickupLocation)
                        {
                            if (CartHelper.FindAddressByName(warehouse.Name) == null)
                            {
                                var address = warehouse.ContactInformation.ToOrderAddress();
                                address.Name = warehouse.Name;
                                Cart.OrderAddresses.Add(address);
                            }

                            shipment.ShippingAddressId  = warehouse.Name;
                            shipment.ShippingMethodName = ShippingManager.PickupShippingMethodName;

                            var instorepickupShippingMethod = ShippingManager.GetShippingMethods("en").ShippingMethod.ToArray().Where(m => m.Name.Equals(ShippingManager.PickupShippingMethodName)).FirstOrDefault();
                            if (instorepickupShippingMethod != null)
                            {
                                shipment.ShippingMethodId = instorepickupShippingMethod.ShippingMethodId;
                            }
                        }

                        Cart.OrderForms[0].Shipments.Add(shipment);
                    }
                }

                Cart.AcceptChanges();
            }
        }
Esempio n. 18
0
        private void AddCustomProperties(LineItem lineItem, Cart cart)
        {
            var item = cart.OrderForms[0].LineItems.FindItemByCatalogEntryId(lineItem.Code);

            //TODO: Let specific model implementation populate these fields, we need to know too much about the model here
            item[Constants.Metadata.LineItem.DisplayName]   = lineItem.Name;
            item[Constants.Metadata.LineItem.ImageUrl]      = lineItem.ImageUrl;
            item[Constants.Metadata.LineItem.Size]          = lineItem.Size;
            item[Constants.Metadata.LineItem.Description]   = lineItem.Description;
            item[Constants.Metadata.LineItem.Color]         = lineItem.Color;
            item[Constants.Metadata.LineItem.ColorImageUrl] = lineItem.ColorImageUrl;
            item[Constants.Metadata.LineItem.ArticleNumber] = lineItem.ArticleNumber;
            item[Constants.Metadata.LineItem.WineRegion]    = lineItem.WineRegion;

            cart.AcceptChanges();
        }
Esempio n. 19
0
        private void AddCustomProperties(LineItem lineItem, Cart cart)
        {
            var item = cart.OrderForms[0].LineItems.FindItemByCatalogEntryId(lineItem.Code);

            item[Constants.Metadata.LineItem.DisplayName]   = lineItem.Name;
            item[Constants.Metadata.LineItem.ImageUrl]      = lineItem.ImageUrl;
            item[Constants.Metadata.LineItem.Size]          = lineItem.Size;
            item[Constants.Metadata.LineItem.Description]   = lineItem.Description;
            item[Constants.Metadata.LineItem.Color]         = lineItem.Color;
            item[Constants.Metadata.LineItem.ColorImageUrl] = lineItem.ColorImageUrl;
            item[Constants.Metadata.LineItem.ArticleNumber] = lineItem.ArticleNumber;
            item[Constants.Metadata.LineItem.WineRegion]    = lineItem.WineRegion;



            cart.AcceptChanges();
        }
Esempio n. 20
0
        private void AddCustomProperties(LineItem lineItem, Cart cart)
        {
            Mediachase.Commerce.Orders.LineItem item = cart.OrderForms[0].LineItems.FindItemByCatalogEntryId(lineItem.Code);

            // Make sure we have all available data on the item before
            // we proceed
            lineItem.UpdateData(item);

            //TODO: Let specific model implementation populate these fields, we need to know too much about the model here
            item[Constants.Metadata.LineItem.DisplayName]   = lineItem.Name;
            item[Constants.Metadata.LineItem.ImageUrl]      = lineItem.ImageUrl;
            item[Constants.Metadata.LineItem.Size]          = lineItem.Size;
            item[Constants.Metadata.LineItem.Description]   = lineItem.Description;
            item[Constants.Metadata.LineItem.Color]         = lineItem.Color;
            item[Constants.Metadata.LineItem.ColorImageUrl] = lineItem.ColorImageUrl;
            item[Constants.Metadata.LineItem.ArticleNumber] = lineItem.ArticleNumber;

            cart.AcceptChanges();
        }
Esempio n. 21
0
        /// <summary>
        /// Create shipment for the first time.
        /// </summary>
        private void CreateDataShipment()
        {
            if (Cart.OrderForms.Count > 0)
            {
                // If switch from MultiShipment to SingleShipment (just demo showcase), remove existing Shipment and Address
                if (Cart.OrderForms[0].Shipments.Count > 1)
                {
                    foreach (Shipment shipment in Cart.OrderForms[0].Shipments)
                    {
                        shipment.Delete();
                    }
                    foreach (OrderAddress address in Cart.OrderAddresses)
                    {
                        address.Delete();
                    }
                    Cart.AcceptChanges();
                }

                Shipment ship = Cart.OrderForms[0].Shipments.ToArray().FirstOrDefault();

                if (ship == null)
                {
                    ship           = Cart.OrderForms[0].Shipments.AddNew();
                    ship.CreatorId = SecurityContext.Current.CurrentUserId.ToString();
                    ship.Created   = DateTime.UtcNow;

                    // Add LineItem to Shipment.
                    int index = 0;
                    foreach (LineItem item in Cart.OrderForms[0].LineItems)
                    {
                        string key = index.ToString();
                        if (ship.LineItemIndexes.Contains(key))
                        {
                            ship.RemoveLineItemIndex(key);
                        }

                        ship.AddLineItemIndex(index, item.Quantity);
                        index++;
                    }
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Saves the and retrieve cart.
        /// </summary>
        /// <param name="testCart">The test cart.</param>
        /// <param name="testPayment">The test payment.</param>
        /// <returns></returns>
        public Cart SaveAndRetrieveCart(Cart testCart, Payment testPayment)
        {
            Cart retrievedCart;

            //Set generic payment properties
            testPayment.Amount           = 3;
            testPayment.BillingAddressId = "15";
            testPayment.CustomerName     = "Harry Potter";
            testPayment.Created          = DateTime.UtcNow;
            testPayment.CreatorId        = "Jimmy Dean";
            testPayment.Modified         = DateTime.UtcNow;
            testCart.OrderForms[0].Payments.Add(testPayment);
            testCart.Status = "Submitted";

            testCart.AcceptChanges();

            retrievedCart = OrderContext.Current.GetCart(Cart.DefaultName, testCart.CustomerId);

            return(retrievedCart);
        }
Esempio n. 23
0
        public void OrderSystem_GetCartsForACustomer()
        {
            Cart firstCart  = null;
            Cart secondCart = null;
            MetaStorageCollectionBase <Cart> carts = null;
            Guid customerId;

            //first add fictitious carts into the db
            customerId = Guid.NewGuid();

            //Create cart 1. This cart is just used to get the lineitem meta class information
            try
            {
                firstCart = OrderHelper.CreateCart(customerId, "FirstTestCart");
                firstCart.AcceptChanges();
            }
            catch (Exception exc)
            {
                if (exc.Message == "'maxValue' must be greater than zero.\r\nParameter name: maxValue")
                {
                    Assert.Fail("Check your ApplicationId");
                }
                else
                {
                    throw exc;
                }
            }

            //Create cart 1. This cart is just used to get the lineitem meta class information
            try
            {
                secondCart = OrderHelper.CreateCart(customerId, "SecondTestCart");
                secondCart.AcceptChanges();
            }
            catch (Exception exc)
            {
                if (exc.Message == "'maxValue' must be greater than zero.\r\nParameter name: maxValue")
                {
                    Assert.Fail("Check your ApplicationId");
                }
                else
                {
                    throw exc;
                }
            }

            try
            {
                carts = Cart.LoadByCustomer(customerId);
            }
            catch (Exception exc)
            {
                Assert.Fail("Error calling Cart.LoadByCustomer method : " + exc.Message);
            }

            if (carts.Count != 2)
            {
                Assert.Fail("Incorrect number of carts found by Cart.LoadByCustomer(). Found: " + carts.Count);
            }

            //cleanup
            firstCart.Delete();
            firstCart.AcceptChanges();
            secondCart.Delete();
            secondCart.AcceptChanges();
        }
Esempio n. 24
0
        public void OrderSystem_LineItemMetaDataSave()
        {
            bool      metaFieldExists  = false;
            MetaField brandField       = null;
            string    fieldName        = "Brand";
            bool      metaFieldAdded   = false;
            string    testForValue     = "Test";
            string    returnedValue    = "";
            Cart      cart             = null;
            Cart      newCart          = null;
            Cart      retrieveTestCart = null;
            Guid      customerId       = Guid.NewGuid();

            //Create cart. This cart is just used to get the lineitem meta class information
            try
            {
                cart = OrderHelper.CreateCartSimple(customerId);
            }
            catch (Exception exc)
            {
                if (exc.Message == "'maxValue' must be greater than zero.\r\nParameter name: maxValue")
                {
                    Assert.Fail("Check your ApplicationId");
                }
                else
                {
                    throw exc;
                }
            }

            //first make sure the meta field exists in the collection for the LineItem  collection
            MetaDataContext context = OrderContext.MetaDataContext;
            MetaClass       mc      = cart.OrderForms[0].LineItems[0].MetaClass;

            for (int i = 0; i < mc.MetaFields.Count; i++)
            {
                if (mc.MetaFields[i].Name.Equals(fieldName, StringComparison.OrdinalIgnoreCase))
                {
                    brandField      = mc.MetaFields[i];
                    metaFieldExists = true;
                    break;
                }
            }

            if (!metaFieldExists)
            {
                brandField = MetaField.Load(context, fieldName);

                if (brandField == null)
                {
                    brandField     = MetaField.Create(context, "Mediachase.Commerce.Orders.System", fieldName, fieldName, "", MetaDataType.ShortString, 100, true, false, false, false, false);
                    metaFieldAdded = true;
                }
                mc.AddField(brandField);
            }

            //use a new customer id for the new cart
            customerId = Guid.NewGuid();

            //Create a new cart that will be used to add meta data to and save
            newCart = OrderHelper.CreateRetrieveOneLineItemCart(customerId);

            //now add a value for this new metafield in the first lineitem in the cart
            newCart.OrderForms[0].LineItems[0][fieldName] = testForValue;
            newCart.AcceptChanges();

            //now retrieve the cart anew and test
            retrieveTestCart = Cart.LoadByCustomerAndName(newCart.CustomerId, newCart.Name);

            //check for the value
            if (retrieveTestCart.OrderForms[0].LineItems[0][fieldName] != null)
            {
                returnedValue = retrieveTestCart.OrderForms[0].LineItems[0][fieldName].ToString();
            }

            if (!metaFieldExists)
            {
                mc.DeleteField(brandField);
            }

            //delete the field if added
            if (metaFieldAdded)
            {
                MetaField.Delete(context, brandField.Id);
            }

            if (testForValue != returnedValue)
            {
                Assert.Fail("Value was not saved");
            }
        }
Esempio n. 25
0
        public void OrderSystem_Payments_AuthorizeNET_CreateNewError()
        {
            CreditCardPayment payment;
            string            cardType = "Visa";
            int expMonth = 4;
            int expYear  = DateTime.UtcNow.AddYears(5).Year;

            // Create cart
            Cart cart = OrderHelper.CreateCartForPaymentPlan();

            // Create payment plan
            PaymentPlan plan = cart.SaveAsPaymentPlan();

            // Set some payment plan values
            // Monthly subscription for a year
            plan.CycleMode      = PaymentPlanCycle.Months;
            plan.CycleLength    = 1;
            plan.MaxCyclesCount = 12;
            plan.StartDate      = DateTime.UtcNow.AddDays(-10);
            plan.EndDate        = DateTime.UtcNow.AddMonths(13);

            //create cc payment to validate test account
            payment                  = (CreditCardPayment)plan.OrderForms[0].Payments[0];
            payment.CardType         = cardType;
            payment.CreditCardNumber = "4012888818888";
            payment.ExpirationMonth  = expMonth;
            payment.ExpirationYear   = expYear;

            // Execute workflow
            try
            {
                plan.RunWorkflow("CartCheckout");
            }
            catch (PaymentException ex)
            {
                if (ex.Type != PaymentException.ErrorType.ProviderError)
                {
                    throw;
                }
                else
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }

            // Update last transaction date
            plan.LastTransactionDate = DateTime.UtcNow;
            // Encrease cycle count
            plan.CompletedCyclesCount++;
            // Save changes
            plan.AcceptChanges();

            plan = OrderContext.Current.GetPaymentPlan(plan.CustomerId, plan.OrderGroupId);

            // Validate payment plan
            Assert.AreEqual(plan.CompletedCyclesCount, 1);
            // Delete payment plan
            plan.Delete();
            plan.AcceptChanges();
            // Assert that payment plan is deleted
            Assert.IsTrue(plan.ObjectState == MetaObjectState.Deleted);

            // Delete cart
            cart.Delete();
            cart.AcceptChanges();
            // Assert that cart is deleted
            Assert.IsTrue(cart.ObjectState == MetaObjectState.Deleted);
        }
Esempio n. 26
0
        public void OrderSystem_Payments_AuthorizeNET_CreateNewAndCancelError()
        {
            CreditCardPayment payment;
            string            cardType = "MasterCard";
            int expMonth = 4;
            int expYear  = DateTime.UtcNow.AddYears(5).Year;

            // Create cart
            Cart cart = OrderHelper.CreateCartForPaymentPlan();

            // Create payment plan
            PaymentPlan plan = cart.SaveAsPaymentPlan();

            // ---------- Step 1. Create subscription -----------

            // Set some payment plan values
            plan.CycleMode           = PaymentPlanCycle.Months;
            plan.CycleLength         = 1;
            plan.MaxCyclesCount      = 12;
            plan.StartDate           = DateTime.UtcNow;
            plan.EndDate             = DateTime.UtcNow.AddMonths(13);
            plan.LastTransactionDate = DateTime.UtcNow;

            //create cc payment to validate test account
            payment                  = (CreditCardPayment)plan.OrderForms[0].Payments[0];
            payment.CardType         = cardType;
            payment.CreditCardNumber = "5424000000000015";
            payment.ExpirationMonth  = expMonth;
            payment.ExpirationYear   = expYear;

            // Execute workflow
            plan.RunWorkflow("CartCheckout");

            // Update last transaction date
            plan.LastTransactionDate = DateTime.UtcNow;
            // Encrease cycle count
            plan.CompletedCyclesCount++;

            // Save changes
            plan.AcceptChanges();

            plan = OrderContext.Current.GetPaymentPlan(plan.CustomerId, plan.OrderGroupId);

            // Validate payment plan
            Assert.IsTrue(!String.IsNullOrEmpty(plan.OrderForms[0].Payments[0].AuthorizationCode));

            // ---------- Step 2. Cancel subscription -----------
            // get cancel status
            PaymentMethodDto dto = PaymentManager.GetPaymentMethodBySystemName("authorize", "en-us", true);

            Assert.IsTrue(dto.PaymentMethod.Count > 0, "Authorize.NET payment method not found for en-us language.");

            PaymentMethodDto.PaymentMethodParameterRow[] rows = (PaymentMethodDto.PaymentMethodParameterRow[])dto.PaymentMethodParameter.Select(String.Format("Parameter = '{0}'", AuthorizePaymentGateway._CancelStatusParameterName));
            Assert.IsTrue(rows != null && rows.Length > 0, "CancelStatus parameter for the Authorize.NET gateway not net.");

            string cancelStatus = rows[0].Value;

            // set status cancel status for the payment plan
            plan.Status = cancelStatus;
            // change AuthorizationCode to generate payment provider error
            plan.OrderForms[0].Payments[0].AuthorizationCode = "000000";

            // Execute workflow
            try
            {
                plan.RunWorkflow("CartCheckout");
            }
            catch (PaymentException ex)
            {
                if (ex.Type != PaymentException.ErrorType.ProviderError)
                {
                    throw;
                }
                else
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }

            // ---------- Step 3. Perform cleanup -----------

            // Delete payment plan
            plan.Delete();
            plan.AcceptChanges();
            // Assert that payment plan is deleted
            Assert.IsTrue(plan.ObjectState == MetaObjectState.Deleted);

            // Delete cart
            cart.Delete();
            cart.AcceptChanges();
            // Assert that cart is deleted
            Assert.IsTrue(cart.ObjectState == MetaObjectState.Deleted);
        }
        private bool UpdateOrderAddress(PaymentMethod currentPayment, TransactionResult transactionDetails2)
        {
            Log.InfoFormat("Updating order address for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
            if (!currentPayment.RequireAddressUpdate)
            {
                Log.InfoFormat("This payment method ({0}) does not require an order address update. Payment with ID:{1} belonging to order with ID: {2}",
                               currentPayment.PaymentMethodCode, currentPayment.Payment.Id, currentPayment.OrderGroupId);
                return(true);
            }

            Address newAddress = currentPayment.GetAddressFromPayEx(transactionDetails2);

            if (newAddress == null)
            {
                return(false);
            }

            Cart         cart            = currentPayment.Cart;
            OrderAddress shippingAddress = GetShippingAddress(cart);

            if (shippingAddress == null)
            {
                Log.ErrorFormat("Could not update address for payment with ID:{0} belonging to order with ID: {1}. Reason: Shipping address was not found!", currentPayment.Payment.Id, currentPayment.OrderGroupId);
                return(false);
            }

            Dictionary <string, string> propertiesToUpdate = new Dictionary <string, string>()
            {
                { GetPropertyName(() => shippingAddress.FirstName), newAddress.FirstName },
                { GetPropertyName(() => shippingAddress.LastName), newAddress.LastName },
                { GetPropertyName(() => shippingAddress.Line1), newAddress.Line1 },
                { GetPropertyName(() => shippingAddress.PostalCode), newAddress.PostCode },
                { GetPropertyName(() => shippingAddress.City), newAddress.City },
                { GetPropertyName(() => shippingAddress.CountryName), newAddress.Country },
                { GetPropertyName(() => shippingAddress.Email), newAddress.Email },
            };

            bool updated = UpdatePropertyValues(shippingAddress, propertiesToUpdate);

            if (!string.IsNullOrWhiteSpace(newAddress.Fullname))
            {
                Log.InfoFormat("Setting customer name of cart to {0} on payment with ID:{1} belonging to order with ID: {2}",
                               newAddress.Fullname, currentPayment.Payment.Id, currentPayment.OrderGroupId);
                cart.CustomerName = newAddress.Fullname;
            }

            try
            {
                if (updated)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        shippingAddress.AcceptChanges();
                        cart.AcceptChanges();
                        scope.Complete();
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                Log.Error("Could not update address for payment. See next log statement for more information", e);
                Log.ErrorFormat("Could not update address for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
                return(false);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, EventArgs e)
        {
            OrderGroup order      = (OrderGroup)Session[_OrderGroupDtoSessionKey];
            bool       cartLoaded = false;
            Cart       cart       = null;

            if (order == null && OrderGroupId > 0)
            {
                if (this.ViewId.StartsWith(_PaymentPlanViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetPaymentPlan(CustomerId, OrderGroupId);
                }
                else if (this.ViewId.StartsWith(_PurchaseOrderViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetPurchaseOrder(CustomerId, OrderGroupId);
                }
                else if (this.ViewId.StartsWith(_ShoppingCartViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetCart(CustomerId, OrderGroupId);
                }
            }

            // if order is still null, create an empty cart
            if (order == null)
            {
                cart       = CreateFreshCart();
                cartLoaded = true;
                Session[_OrderGroupDtoSessionKey] = cart;
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            if (cartLoaded)
            {
                dic.Add(_OrderContextObjectString, cart);
            }
            else
            {
                dic.Add(_OrderContextObjectString, order);
            }

            // Call tabs save
            OrderGroupEdit.SaveChanges(dic);
            ViewControl.SaveChanges(dic);

            Cart cartFromSession = order as Cart;

            if (cartFromSession != null)             // if we're in create mode, save cart as order (payment plan, cart)
            {
                if (this.ViewId.StartsWith(_PaymentPlanViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.SaveAsPaymentPlan();
                }
                else if (this.ViewId.StartsWith(_PurchaseOrderViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.SaveAsPurchaseOrder();
                }
                else if (this.ViewId.StartsWith(_ShoppingCartViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.AcceptChanges();
                }
            }
            else
            {
                // Persist changes to the database
                order.AcceptChanges();
            }

            Session.Remove(_OrderGroupDtoSessionKey);
        }
Esempio n. 29
0
 /// <summary>
 /// Handles the Cancel event of the CancelButton control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Cancel_Click(object sender, EventArgs e)
 {
     CartHelper.Reset();
     Cart.AcceptChanges();
     Context.RedirectFast(GetUrl(Settings.CheckoutPage));
 }
Esempio n. 30
0
        private int PlaceOneClickOrder(CartHelper cartHelper, PlaceOrderInfo orderInfo)
        {
            Cart cart = cartHelper.Cart;

            CustomerContact currentContact = CustomerContext.Current.GetContactById(orderInfo.CustomerId);

            if (currentContact == null)
            {
                throw new NullReferenceException("Cannot load customer with id: " + orderInfo.CustomerId.ToString());
            }

            OrderGroupWorkflowManager.RunWorkflow(cart, OrderGroupWorkflowManager.CartCheckOutWorkflowName);
            cart.CustomerId   = orderInfo.CustomerId;
            cart.CustomerName = currentContact.FullName;

            if (currentContact.PreferredBillingAddress != null)
            {
                OrderAddress orderBillingAddress = StoreHelper.ConvertToOrderAddress(currentContact.PreferredBillingAddress);
                int          billingAddressId    = cart.OrderAddresses.Add(orderBillingAddress);
                cart.OrderForms[0].BillingAddressId = orderBillingAddress.Name;
            }
            if (currentContact.PreferredShippingAddress != null)
            {
                int shippingAddressId = cart.OrderAddresses.Add(StoreHelper.ConvertToOrderAddress(currentContact.PreferredShippingAddress));
            }

            if (cart.OrderAddresses.Count == 0)
            {
                CustomerAddress address = currentContact.ContactAddresses.FirstOrDefault();
                if (address != null)
                {
                    int defaultAddressId = cart.OrderAddresses.Add(StoreHelper.ConvertToOrderAddress(address));
                    cart.OrderForms[0].BillingAddressId = address.Name;
                }
            }

            var po = cart.SaveAsPurchaseOrder();

            // These does not persist
            po.OrderForms[0].Created  = orderInfo.OrderDate;
            po.OrderForms[0].Modified = orderInfo.OrderDate;
            po.Created  = orderInfo.OrderDate;
            po.Modified = orderInfo.OrderDate;

            currentContact.LastOrder = po.Created;
            currentContact.SaveChanges();

            // Add note to purchaseOrder
            OrderNotesManager.AddNoteToPurchaseOrder(po, "", OrderNoteTypes.System, orderInfo.CustomerId);
            // OrderNotesManager.AddNoteToPurchaseOrder(po, "Created: " + po.Created, OrderNoteTypes.System, orderInfo.CustomerId);

            po.AcceptChanges();

            SetOrderDates(po.Id, orderInfo.OrderDate);

            //Add do Find index
            // OrderHelper.CreateOrderToFind(po);

            // Remove old cart
            cart.Delete();
            cart.AcceptChanges();
            return(po.Id);
        }
Esempio n. 31
0
        /// <summary>
        /// Handles the ItemCommand event of the addressBook control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.ListViewCommandEventArgs"/> instance containing the event data.</param>
        void addressBook_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (string.IsNullOrEmpty(e.CommandArgument.ToString()) || _currentContact == null)
            {
                return;
            }

            var addressId = e.CommandArgument.ToString();
            var ca        = _currentContact.ContactAddresses.FirstOrDefault(x => x.AddressId.ToString().ToLower().Equals(addressId.ToLower()));

            if (ca == null)
            {
                return;
            }

            var address = _cartHelper.FindAddressByName(ca.Name);

            if (address == null)
            {
                address = ConvertCustomerToOrderAddress(ca);
                Cart.OrderAddresses.Add(address);
            }
            else
            {
                CustomerAddress.CopyCustomerAddressToOrderAddress(ca, address);
            }

            // Add address to BillingAddressId/ShippingAddressId
            if (addressType.Value.Equals("billing"))
            {
                Cart.OrderForms[0].BillingAddressId = address.Name;
            }
            else
            {
                int shipId;
                if (int.TryParse(shipmentId.Value, out shipId))
                {
                    var shipment = Cart.OrderForms[0].Shipments.ToArray().FirstOrDefault(s => s.Id == shipId);
                    if (shipment != null)
                    {
                        shipment.ShippingAddressId = ca.Name;
                        OrderGroupWorkflowManager.RunWorkflow(Cart, OrderGroupWorkflowManager.CartPrepareWorkflowName);
                    }
                }
                else
                {
                    var shipment = Cart.OrderForms[0].Shipments.ToArray().FirstOrDefault()
                                   ?? new Shipment()
                    {
                        CreatorId = SecurityContext.Current.CurrentUserId.ToString(),
                        Created   = DateTime.UtcNow
                    };

                    shipment.ShippingAddressId = address.Name;

                    if (Cart.OrderForms[0].Shipments.Count < 1)
                    {
                        Cart.OrderForms[0].Shipments.Add(shipment);
                    }

                    if (!shipment.ShippingMethodId.Equals(Guid.Empty))
                    {
                        //Calculate shipping in case choosing shipping method first.
                        OrderGroupWorkflowManager.RunWorkflow(Cart, OrderGroupWorkflowManager.CartPrepareWorkflowName);
                    }
                }
            }

            Cart.AcceptChanges();
            //redirect after post
            Context.RedirectFast(Request.RawUrl + "#ShippingRegion" + shipmentId.Value);
        }
        private void AddCustomProperties(LineItem lineItem, Cart cart)
        {
            var item = cart.OrderForms[0].LineItems.FindItemByCatalogEntryId(lineItem.Code);

            //TODO: Let specific model implementation populate these fields, we need to know too much about the model here
            item[Constants.Metadata.LineItem.DisplayName] = lineItem.Name;
            item[Constants.Metadata.LineItem.ImageUrl] = lineItem.ImageUrl;
            item[Constants.Metadata.LineItem.Size] = lineItem.Size;
            item[Constants.Metadata.LineItem.Description] = lineItem.Description;
            item[Constants.Metadata.LineItem.Color] = lineItem.Color;
            item[Constants.Metadata.LineItem.ColorImageUrl] = lineItem.ColorImageUrl;
            item[Constants.Metadata.LineItem.ArticleNumber] = lineItem.ArticleNumber;
            item[Constants.Metadata.LineItem.WineRegion] = lineItem.WineRegion;

            cart.AcceptChanges();
        }
Esempio n. 33
0
        private void AddCustomProperties(LineItem lineItem, Cart cart)
        {
            Mediachase.Commerce.Orders.LineItem item = cart.OrderForms[0].LineItems.FindItemByCatalogEntryId(lineItem.Code);

            // Make sure we have all available data on the item before
            // we proceed
            lineItem.UpdateData(item);

            //TODO: Let specific model implementation populate these fields, we need to know too much about the model here
            item[Constants.Metadata.LineItem.DisplayName] = lineItem.Name;
            item[Constants.Metadata.LineItem.ImageUrl] = lineItem.ImageUrl;
            item[Constants.Metadata.LineItem.Size] = lineItem.Size;
            item[Constants.Metadata.LineItem.Description] = lineItem.Description;
            item[Constants.Metadata.LineItem.Color] = lineItem.Color;
            item[Constants.Metadata.LineItem.ColorImageUrl] = lineItem.ColorImageUrl;
            item[Constants.Metadata.LineItem.ArticleNumber] = lineItem.ArticleNumber;

            cart.AcceptChanges();
        }