Exemple #1
0
        public void OrderTests_Test4()
        {
            var       createdCart = CartFactory.GetOrCreateCart(AnonShopperMsgHandler);
            const int index       = 0;
            var       product     = ProductFactory.GetProducts(AnonShopperMsgHandler, index, 13).Items.First();
            const int itemQty     = 1;
            var       item        = CartItemFactory.AddItemToCart(AnonShopperMsgHandler,
                                                                  new CartItem
            {
                Product =
                    new Product
                {
                    ProductCode = product.ProductCode
                },
                Quantity = itemQty
            });
            var order   = OrderFactory.CreateOrderFromCart(AnonShopperMsgHandler, createdCart.Id);
            var billing = BillingInfoFactory.SetBillingInfo(AnonShopperMsgHandler, new BillingInfo()
            {
                PaymentType    = "Check",
                BillingContact = new Mozu.Api.Contracts.Core.Contact
                {
                    Address = new Address
                    {
                        Address1        = string.Format("{0} {1}", Generator.RandomString(8, Generator.RandomCharacterGroup.NumericOnly), Generator.RandomString(75, Generator.RandomCharacterGroup.AlphaNumericOnly)),
                        Address2        = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address3        = Generator.RandomString(20, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address4        = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        CityOrTown      = Generator.RandomString(25, Generator.RandomCharacterGroup.AlphaOnly),
                        CountryCode     = "US",
                        PostalOrZipCode = "78713",
                        StateOrProvince = "TX"
                    },
                    CompanyOrOrganization = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                    Email               = Generator.RandomEmailAddress(),
                    FirstName           = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaOnly),
                    MiddleNameOrInitial = Generator.RandomString(1, Generator.RandomCharacterGroup.AlphaOnly),
                    LastNameOrSurname   = Generator.RandomString(35, Generator.RandomCharacterGroup.AlphaOnly),
                    PhoneNumbers        = new Mozu.Api.Contracts.Core.Phone
                    {
                        Home = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Mobile = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Work = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly))
                    }
                },
                IsSameBillingShippingAddress = true
            }, order.Id);

            var shipping = FulfillmentInfoFactory.SetFulFillmentInfo(AnonShopperMsgHandler, new FulfillmentInfo()
            {
                IsDestinationCommercial = false,
                FulfillmentContact      = new Mozu.Api.Contracts.Core.Contact
                {
                    Address = new Address
                    {
                        Address1        = string.Format("{0} {1}", Generator.RandomString(8, Generator.RandomCharacterGroup.NumericOnly), Generator.RandomString(75, Generator.RandomCharacterGroup.AlphaNumericOnly)),
                        Address2        = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address3        = Generator.RandomString(20, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address4        = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        CityOrTown      = Generator.RandomString(25, Generator.RandomCharacterGroup.AlphaOnly),
                        CountryCode     = "US",
                        PostalOrZipCode = "78713",
                        StateOrProvince = "TX"
                    },
                    CompanyOrOrganization = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                    Email               = Generator.RandomEmailAddress(),
                    FirstName           = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaOnly),
                    MiddleNameOrInitial = Generator.RandomString(1, Generator.RandomCharacterGroup.AlphaOnly),
                    LastNameOrSurname   = Generator.RandomString(35, Generator.RandomCharacterGroup.AlphaOnly),
                    PhoneNumbers        = new Mozu.Api.Contracts.Core.Phone
                    {
                        Home = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Mobile = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Work = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly))
                    }
                },
                ShippingMethodCode = "CUSTOM_FLAT_RATE_PER_ORDER_EXACT_AMOUNT",
                ShippingMethodName = "Flat Rate"
            }, order.Id);
            var getOrderActions = OrderFactory.GetAvailableActions(ApiMsgHandler, order.Id);

            Assert.AreEqual(getOrderActions.Count, 1);
            Assert.IsTrue(getOrderActions[0].Equals("SubmitOrder"));
            var status = OrderFactory.PerformOrderAction(AnonShopperMsgHandler, new OrderAction()
            {
                ActionName = "SubmitOrder"
            }, order.Id);
            var getOrder          = OrderFactory.GetOrder(ApiMsgHandler, order.Id);
            var getPaymentActions = PaymentFactory.GetAvailablePaymentActions(ApiMsgHandler, order.Id, getOrder.Payments[0].Id);

            Assert.AreEqual(getPaymentActions.Count, 3);
            Assert.IsTrue(getPaymentActions[0].Equals("ApplyCheck") || getPaymentActions[0].Equals("VoidPayment") || getPaymentActions[0].Equals("DeclinePayment"));
            Assert.IsTrue(getPaymentActions[1].Equals("ApplyCheck") || getPaymentActions[1].Equals("VoidPayment") || getPaymentActions[1].Equals("DeclinePayment"));
            Assert.IsTrue(getPaymentActions[2].Equals("ApplyCheck") || getPaymentActions[2].Equals("VoidPayment") || getPaymentActions[2].Equals("DeclinePayment"));
            var paymentAction = new PaymentAction()
            {
                ActionName  = "ApplyCheck",
                CheckNumber = "12345",
                Amount      = Convert.ToDecimal(getOrder.Total)
            };
            var orderPayment1 = PaymentFactory.PerformPaymentAction(ApiMsgHandler, paymentAction, order.Id, getOrder.Payments[0].Id);

            Assert.AreEqual(orderPayment1.PaymentStatus, "Paid");
            Assert.AreEqual(orderPayment1.Payments[0].Status, "Collected");
            Assert.AreEqual(orderPayment1.Payments[0].AmountCollected, getOrder.Total);
            Assert.AreEqual(orderPayment1.Payments[0].Interactions.Count, 2);
            Assert.IsTrue(orderPayment1.Payments[0].Interactions[1].Status.Equals("Captured"));
            Assert.IsTrue(orderPayment1.Payments[0].Interactions[1].InteractionType.Equals("ApplyCheck"));
            Assert.IsTrue(orderPayment1.Payments[0].Interactions[1].CheckNumber.Equals("12345"));
            Assert.AreEqual(orderPayment1.Payments[0].Interactions[1].Amount, getOrder.Total);
        }
Exemple #2
0
        public void OrderTests_Test2()
        {
            var       createdCart = CartFactory.GetOrCreateCart(AnonShopperMsgHandler);
            const int index       = 0;
            var       product     = ProductFactory.GetProducts(AnonShopperMsgHandler, index, 13).Items.First();
            const int itemQty     = 3;
            var       item        = CartItemFactory.AddItemToCart(AnonShopperMsgHandler,
                                                                  new CartItem
            {
                Product =
                    new Product
                {
                    ProductCode = product.ProductCode
                },
                Quantity = itemQty
            });
            var getUserCart = CartFactory.GetUserCart(ApiMsgHandler, createdCart.UserId);
            var order       = OrderFactory.CreateOrderFromCart(AnonShopperMsgHandler, createdCart.Id);
            var billing     = BillingInfoFactory.SetBillingInfo(AnonShopperMsgHandler, new BillingInfo()
            {
                PaymentType    = "Check",
                BillingContact = new Mozu.Api.Contracts.Core.Contact
                {
                    Address = new Address
                    {
                        Address1        = string.Format("{0} {1}", Generator.RandomString(8, Generator.RandomCharacterGroup.NumericOnly), Generator.RandomString(75, Generator.RandomCharacterGroup.AlphaNumericOnly)),
                        Address2        = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address3        = Generator.RandomString(20, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address4        = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        CityOrTown      = Generator.RandomString(25, Generator.RandomCharacterGroup.AlphaOnly),
                        CountryCode     = "US",
                        PostalOrZipCode = "78713",
                        StateOrProvince = "TX"
                    },
                    CompanyOrOrganization = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                    Email               = Generator.RandomEmailAddress(),
                    FirstName           = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaOnly),
                    MiddleNameOrInitial = Generator.RandomString(1, Generator.RandomCharacterGroup.AlphaOnly),
                    LastNameOrSurname   = Generator.RandomString(35, Generator.RandomCharacterGroup.AlphaOnly),
                    PhoneNumbers        = new Mozu.Api.Contracts.Core.Phone
                    {
                        Home = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Mobile = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Work = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly))
                    }
                },
                IsSameBillingShippingAddress = true
            }, order.Id);

            var shipping = FulfillmentInfoFactory.SetFulFillmentInfo(AnonShopperMsgHandler, new FulfillmentInfo()
            {
                IsDestinationCommercial = false,
                FulfillmentContact      = new Mozu.Api.Contracts.Core.Contact
                {
                    Address = new Address
                    {
                        Address1        = string.Format("{0} {1}", Generator.RandomString(8, Generator.RandomCharacterGroup.NumericOnly), Generator.RandomString(75, Generator.RandomCharacterGroup.AlphaNumericOnly)),
                        Address2        = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address3        = Generator.RandomString(20, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        Address4        = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaNumericOnly),
                        CityOrTown      = Generator.RandomString(25, Generator.RandomCharacterGroup.AlphaOnly),
                        CountryCode     = "US",
                        PostalOrZipCode = "78713",
                        StateOrProvince = "TX"
                    },
                    CompanyOrOrganization = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
                    Email               = Generator.RandomEmailAddress(),
                    FirstName           = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaOnly),
                    MiddleNameOrInitial = Generator.RandomString(1, Generator.RandomCharacterGroup.AlphaOnly),
                    LastNameOrSurname   = Generator.RandomString(35, Generator.RandomCharacterGroup.AlphaOnly),
                    PhoneNumbers        = new Mozu.Api.Contracts.Core.Phone
                    {
                        Home = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Mobile = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                               Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly)),
                        Work = string.Format("{0}-{1}-{2}", Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(3, Generator.RandomCharacterGroup.NumericOnly),
                                             Generator.RandomString(4, Generator.RandomCharacterGroup.NumericOnly))
                    }
                },
                ShippingMethodCode = "CUSTOM_FLAT_RATE_PER_ORDER_EXACT_AMOUNT",
                ShippingMethodName = "Flat Rate"
            }, order.Id);
            var getOrder = OrderFactory.GetOrder(AnonShopperMsgHandler, order.Id);

            Assert.IsTrue(billing.PaymentType.Equals("Check"));
            Assert.IsTrue(billing.BillingContact.Address.StateOrProvince.Equals("TX"));
            Assert.IsTrue(billing.BillingContact.Address.PostalOrZipCode.Equals("78717"));
            Assert.IsTrue(billing.IsSameBillingShippingAddress);
            Assert.IsTrue(shipping.FulfillmentContact.Address.PostalOrZipCode.Equals("78726"));
            Assert.IsTrue(shipping.FulfillmentContact.Address.StateOrProvince.Equals("TX"));
            Assert.IsFalse(Convert.ToBoolean(shipping.IsDestinationCommercial));
            Assert.IsTrue(shipping.ShippingMethodCode.Equals("CUSTOM_FLAT_RATE_PER_ORDER_EXACT_AMOUNT"));
            Assert.IsTrue(shipping.ShippingMethodName.Equals("Flat Rate"));
            Assert.AreEqual(getOrder.Subtotal, getUserCart.Subtotal);
            Assert.AreEqual(getOrder.DiscountTotal, getUserCart.DiscountTotal);
            Assert.AreEqual(getOrder.DiscountedTotal, getUserCart.DiscountedTotal);
            Assert.AreEqual(getOrder.ShippingTotal, 15);
        }