Beispiel #1
0
        protected virtual orderModel.PaymentIn ToOrderModel(cartModel.Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            var retVal = AbstractTypeFactory <orderModel.PaymentIn> .TryCreateInstance();

            retVal.Currency       = payment.Currency;
            retVal.DiscountAmount = payment.DiscountAmount;
            retVal.Price          = payment.Price;
            retVal.TaxPercentRate = payment.TaxPercentRate;
            retVal.TaxType        = payment.TaxType;

            retVal.GatewayCode   = payment.PaymentGatewayCode;
            retVal.Sum           = payment.Amount;
            retVal.PaymentStatus = PaymentStatus.New;
            if (payment.BillingAddress != null)
            {
                retVal.BillingAddress     = payment.BillingAddress;
                retVal.BillingAddress.Key = null;
            }
            retVal.TaxDetails = payment.TaxDetails;
            return(retVal);
        }
		public static coreModel.Payment ToCoreModel(this webModel.Payment payment)
		{
			var retVal = new coreModel.Payment();
			retVal.InjectFrom(payment);

			retVal.Currency = payment.Currency;

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

			return retVal;
		}
        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);
        }
		public static Payment ToCoreModel(this PaymentEntity entity)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			var retVal = new Payment();
			retVal.InjectFrom(entity);
			retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);

			if (entity.Addresses != null && entity.Addresses.Any())
			{
				retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
			}
			return retVal;
		}
        public static PaymentIn ToCoreModel(this coreModel.Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException("payment");
            }

            var retVal = new PaymentIn();

            retVal.InjectFrom(payment);
            retVal.Currency    = payment.Currency;
            retVal.GatewayCode = payment.PaymentGatewayCode;
            retVal.Sum         = payment.Amount;

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

            return(retVal);
        }
        private static ShoppingCart GetInvalidTestCart(string id)
        {
            var cart = new ShoppingCart
            {
                Id          = id,
                Currency    = "USD",
                CustomerId  = "Test Customer",
                StoreId     = "test store",
                CreatedDate = DateTime.Now,
                Addresses   = new[]
                {
                    new CartAddress {
                        AddressType  = CartAddressType.Shipping,
                        Phone        = "+68787687",
                        PostalCode   = "19142",
                        CountryCode  = "US",
                        CountryName  = "United states",
                        Email        = "*****@*****.**",
                        FirstName    = "first name",
                        LastName     = "last name",
                        Line1        = "6025 Greenway Ave",
                        City         = "Philadelphia",
                        RegionId     = "PA",
                        RegionName   = "Pennsylvania",
                        Organization = "org1"
                    }
                }.ToList(),
                Discounts = new[] { new CartDiscount
                                    {
                                        PromotionId    = "testPromotion",
                                        Currency       = "USD",
                                        DiscountAmount = 12,
                                    } },
                Coupon = "ssss"
            };
            var item1 = new CartLineItem
            {
                Id                 = Guid.NewGuid().ToString(),
                ListPrice          = 10,
                ExtendedPrice      = 20,
                ProductId          = "shoes",
                CatalogId          = "catalog",
                Currency           = "USD",
                CategoryId         = "category",
                Name               = "shoes",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "itemPromotion",
                        Currency       = "USD",
                        DiscountAmount = 12
                    }
                }
            };
            var item2 = new CartLineItem
            {
                Id                 = Guid.NewGuid().ToString(),
                ListPrice          = 100,
                ExtendedPrice      = 200,
                ProductId          = "t-shirt",
                CatalogId          = "catalog",
                CategoryId         = "category",
                Currency           = "USD",
                Name               = "t-shirt",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = "USD",
                        DiscountAmount = 12
                    }
                }
            };

            cart.Items = new List <CartLineItem> {
                item1, item2
            };

            var shipment = new CartShipment
            {
                Id              = Guid.NewGuid().ToString(),
                Currency        = "USD",
                DeliveryAddress = new CartAddress
                {
                    City         = "Philadelphia",
                    CountryName  = "United states",
                    Phone        = "+68787687",
                    PostalCode   = "19142",
                    CountryCode  = "US",
                    Email        = "*****@*****.**",
                    FirstName    = "first name",
                    LastName     = "last name",
                    Line1        = "6025 Greenway Ave",
                    RegionId     = "PA",
                    RegionName   = "Pennsylvania",
                    Organization = "org1"
                },
                Discounts = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = "USD",
                        DiscountAmount = 12,
                    }
                }
            };

            cart.Shipments = new List <CartShipment> {
                shipment
            };

            var payment = new CartPayment
            {
                Id = Guid.NewGuid().ToString(),
                PaymentGatewayCode = "PayPal",
                Currency           = "USD",
                Amount             = 10,
                OuterId            = "et"
            };

            cart.Payments = new List <CartPayment> {
                payment
            };

            return(cart);
        }
        private static ShoppingCart GetTestCart(string id)
        {
            var cart = new ShoppingCart
            {
                Id          = id,
                Currency    = CurrencyCodes.USD,
                CustomerId  = "Test Customer",
                StoreId     = "test store",
                CreatedDate = DateTime.Now,
                Addresses   = new[]
                {
                    new CartAddress {
                        AddressType  = CartAddressType.Shipping,
                        Phone        = "+68787687",
                        PostalCode   = "60602",
                        CountryCode  = "US",
                        CountryName  = "United states",
                        Email        = "*****@*****.**",
                        FirstName    = "first name",
                        LastName     = "last name",
                        Line1        = "45 Fremont Street",
                        City         = "Los Angeles",
                        RegionId     = "CA",
                        Organization = "org1"
                    }
                }.ToList(),
                Discounts = new[] { new CartDiscount
                                    {
                                        PromotionId    = "testPromotion",
                                        Currency       = CurrencyCodes.USD,
                                        DiscountAmount = 12,
                                    } },
                Coupon = new CartCoupon
                {
                    CouponCode = "ssss"
                }
            };
            var item1 = new CartLineItem
            {
                ListPrice          = 10,
                ExtendedPrice      = 20,
                ProductId          = "shoes",
                CatalogId          = "catalog",
                Currency           = CurrencyCodes.USD,
                CategoryId         = "category",
                Name               = "shoes",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "itemPromotion",
                        Currency       = CurrencyCodes.USD,
                        DiscountAmount = 12
                    }
                }
            };
            var item2 = new CartLineItem
            {
                ListPrice          = 100,
                ExtendedPrice      = 200,
                ProductId          = "t-shirt",
                CatalogId          = "catalog",
                CategoryId         = "category",
                Currency           = CurrencyCodes.USD,
                Name               = "t-shirt",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = CurrencyCodes.USD,
                        DiscountAmount = 12
                    }
                }
            };

            cart.Items = new List <CartLineItem> {
                item1, item2
            };

            var shipment = new CartShipment
            {
                Currency        = CurrencyCodes.USD,
                DeliveryAddress = new CartAddress
                {
                    City         = "london",
                    CountryName  = "England",
                    Phone        = "+68787687",
                    PostalCode   = "2222",
                    CountryCode  = "ENG",
                    Email        = "*****@*****.**",
                    FirstName    = "first name",
                    LastName     = "last name",
                    Line1        = "line 1",
                    Organization = "org1"
                },
                Discounts = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = CurrencyCodes.USD,
                        DiscountAmount = 12,
                    }
                }
            };

            cart.Shipments = new List <CartShipment> {
                shipment
            };

            var payment = new CartPayment
            {
                PaymentGatewayCode = "PayPal",
                Currency           = CurrencyCodes.USD,
                Amount             = 10,
                OuterId            = "et"
            };

            cart.Payments = new List <CartPayment> {
                payment
            };

            return(cart);
        }
        private static ShoppingCart GetTestCart(string id)
        {
            var cart = new ShoppingCart
            {
                Id = id,
                Currency = CurrencyCodes.USD,
                CustomerId = "Test Customer",
                StoreId = "test store",
                CreatedDate = DateTime.Now,
                Addresses = new[]
				{
					new CartAddress {	
					AddressType = CartAddressType.Shipping, 
					Phone = "+68787687",
					PostalCode = "60602",
					CountryCode = "US",
					CountryName = "United states",
					Email = "*****@*****.**",
					FirstName = "first name",
					LastName = "last name",
					Line1 = "45 Fremont Street",
                    City = "Los Angeles",
                    RegionId = "CA",
					Organization = "org1"
					}
				}.ToList(),
                Discounts = new[] { new CartDiscount
                    {
                        PromotionId = "testPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12,
                        
                    }
                },
                Coupon = new CartCoupon
                {
                    CouponCode = "ssss"
                }
                
            };
            var item1 = new CartLineItem
            {
                ListPrice = 10,
                ExtendedPrice = 20,
                ProductId = "shoes",
                CatalogId = "catalog",
                Currency = CurrencyCodes.USD,
                CategoryId = "category",
                Name = "shoes",
                Quantity = 2,
                ShipmentMethodCode = "EMS",
                Discounts = new[] { 
                    new CartDiscount
                    {
                        PromotionId = "itemPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12
                        
                    }
                }
            };
            var item2 = new CartLineItem
            {
                ListPrice = 100,
                ExtendedPrice = 200,
                ProductId = "t-shirt",
                CatalogId = "catalog",
                CategoryId = "category",
                Currency = CurrencyCodes.USD,
                Name = "t-shirt",
                Quantity = 2,
                ShipmentMethodCode = "EMS",
                Discounts = new[]{ 
                    new CartDiscount
                    {
                        PromotionId = "testPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12
                    }
                }
            };
            cart.Items = new List<CartLineItem> { item1, item2 };

            var shipment = new CartShipment
            {
                Currency = CurrencyCodes.USD,
                DeliveryAddress = new CartAddress
                {
                    City = "london",
                    CountryName = "England",
                    Phone = "+68787687",
                    PostalCode = "2222",
                    CountryCode = "ENG",
                    Email = "*****@*****.**",
                    FirstName = "first name",
                    LastName = "last name",
                    Line1 = "line 1",
                    Organization = "org1"
                },
                Discounts = new[] {
                    new CartDiscount
                    {
                        PromotionId = "testPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12,
                        
                    }
                }
            };
            cart.Shipments = new List<CartShipment> { shipment };

            var payment = new CartPayment
            {
                PaymentGatewayCode = "PayPal",
                Currency = CurrencyCodes.USD,
                Amount = 10,
                OuterId = "et"
            };
            cart.Payments = new List<CartPayment> { payment };

            return cart;
        }