예제 #1
0
		public static webModel.Payment ToWebModel(this coreModel.Payment payment)
		{
			var retVal = new webModel.Payment();
			retVal.InjectFrom(payment);
			retVal.Currency = payment.Currency;

			if (payment.BillingAddress != null)
				retVal.BillingAddress = payment.BillingAddress.ToWebModel();

			return retVal;
		}
예제 #2
0
        public static webModel.Payment ToWebModel(this coreModel.Payment payment)
        {
            var retVal = new webModel.Payment();

            retVal.InjectFrom(payment);
            retVal.Currency = payment.Currency;

            if (payment.BillingAddress != null)
            {
                retVal.BillingAddress = payment.BillingAddress.ToWebModel();
            }

            return(retVal);
        }
예제 #3
0
        public void TestCheckout()
        {
            var controller = GetCartController();
            var result     = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult <webModel.ShoppingCart>;
            var cart       = result.Content;

            var deliveryAddress = cart.Addresses.FirstOrDefault(x => x.Type == AddressType.Shipping);

            if (deliveryAddress == null)
            {
                //Enter delivery address
                deliveryAddress = new webModel.Address
                {
                    Type         = AddressType.Shipping,
                    City         = "london",
                    Phone        = "+68787687",
                    PostalCode   = "2222",
                    CountryCode  = "ENG",
                    CountryName  = "England",
                    Email        = "*****@*****.**",
                    FirstName    = "first name",
                    LastName     = "last name",
                    Organization = "org1"
                };
                //cart.Addresses.Add(deliveryAddress);
            }
            deliveryAddress.Line1 = "Wishing Zephyr Limits, Coffee Creek";

            //Save changes
            controller.Update(cart);

            result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult <webModel.ShoppingCart>;
            cart   = result.Content;

            //Select appropriate shipment method
            var shipmentMethodResult = controller.GetShipmentMethods(cart.Id) as OkNegotiatedContentResult <webModel.ShippingMethod[]>;
            var shipmentMethod       = shipmentMethodResult.Content.FirstOrDefault();
            var shipment             = new webModel.Shipment
            {
                DeliveryAddress    = deliveryAddress,
                Currency           = shipmentMethod.Currency,
                ShipmentMethodCode = shipmentMethod.ShipmentMethodCode,
                ShippingPrice      = shipmentMethod.Price
            };

            cart.Shipments.Add(shipment);

            //Save changes
            controller.Update(cart);
            result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult <webModel.ShoppingCart>;
            cart   = result.Content;

            //Select payment method

            var paymentMethodResults = controller.GetPaymentMethods(cart.Id) as OkNegotiatedContentResult <webModel.PaymentMethod[]>;
            var paymentMethod        = paymentMethodResults.Content.FirstOrDefault();

            //Enter billing address
            var billingAddress = new webModel.Address
            {
                Type         = AddressType.Billing,
                City         = "london",
                Phone        = "+68787687",
                PostalCode   = "2222",
                CountryCode  = "ENG",
                CountryName  = "England",
                Email        = "*****@*****.**",
                FirstName    = "first name",
                LastName     = "last name",
                Line1        = "line 1",
                Organization = "org1"
            };

            var payment = new webModel.Payment
            {
                PaymentGatewayCode = paymentMethod.GatewayCode,
                BillingAddress     = billingAddress,
                Currency           = cart.Currency,
                Amount             = cart.Total
            };

            cart.Payments.Add(payment);
            //Save changes
            controller.Update(cart);
            result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult <webModel.ShoppingCart>;
            cart   = result.Content;

            //Next it call customer order method create order form cart
        }
		public void TestCheckout()
		{
			var controller = GetCartController();
			var result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult<webModel.ShoppingCart>;
			var cart = result.Content;

			var deliveryAddress = cart.Addresses.FirstOrDefault(x=>x.Type == AddressType.Shipping);
			if(deliveryAddress == null)
			{
				//Enter delivery address
				deliveryAddress = new webModel.Address
				{
					Type = AddressType.Shipping,
					City = "london",
					Phone = "+68787687",
					PostalCode = "2222",
					CountryCode = "ENG",
					CountryName = "England",
					Email = "*****@*****.**",
					FirstName = "first name",
					LastName = "last name",
					Organization = "org1"
				};
				//cart.Addresses.Add(deliveryAddress);

			}
			deliveryAddress.Line1 = "Wishing Zephyr Limits, Coffee Creek";
		
			//Save changes
			controller.Update(cart);

			result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult<webModel.ShoppingCart>;
			cart = result.Content;

			//Select appropriate shipment method
			var shipmentMethodResult = controller.GetShipmentMethods(cart.Id) as OkNegotiatedContentResult<webModel.ShippingMethod[]>;
			var shipmentMethod = shipmentMethodResult.Content.FirstOrDefault();
			var shipment = new webModel.Shipment
			{
				DeliveryAddress = deliveryAddress,
				Currency = shipmentMethod.Currency,
				ShipmentMethodCode = shipmentMethod.ShipmentMethodCode,
				ShippingPrice = shipmentMethod.Price
			};
			cart.Shipments.Add(shipment);

			//Save changes
			controller.Update(cart);
			result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult<webModel.ShoppingCart>;
			cart = result.Content;

			//Select payment method

			var paymentMethodResults = controller.GetPaymentMethods(cart.Id) as OkNegotiatedContentResult<webModel.PaymentMethod[]>;
			var paymentMethod = paymentMethodResults.Content.FirstOrDefault();

			//Enter billing address
			var billingAddress = new webModel.Address
			{
				Type = AddressType.Billing,
				City = "london",
				Phone = "+68787687",
				PostalCode = "2222",
				CountryCode = "ENG",
				CountryName = "England",
				Email = "*****@*****.**",
				FirstName = "first name",
				LastName = "last name",
				Line1 = "line 1",
				Organization = "org1"
			};
		
			var payment = new webModel.Payment
			{
				PaymentGatewayCode = paymentMethod.GatewayCode,
				BillingAddress = billingAddress,
				Currency = cart.Currency,
				Amount = cart.Total
			};
			cart.Payments.Add(payment);
			//Save changes
			controller.Update(cart);
			result = controller.GetCurrentCart("testSite", null) as OkNegotiatedContentResult<webModel.ShoppingCart>;
			cart = result.Content;

			//Next it call customer order method create order form cart
		}