internal static CartAddress GetBillingAddressFromCheckoutState(OrdersManager ordersManager, CheckoutState checkoutState)
        {
            CartAddress billingAddress = ordersManager.CreateCartAddress();
            billingAddress.FirstName = checkoutState.BillingFirstName;
            billingAddress.LastName = checkoutState.BillingLastName;
            billingAddress.Email = checkoutState.BillingEmail;
            billingAddress.Address = checkoutState.BillingAddress1;
            billingAddress.Address2 = checkoutState.BillingAddress2;
            billingAddress.AddressType = AddressType.Billing;
            billingAddress.City = checkoutState.BillingCity;
            billingAddress.PostalCode = checkoutState.BillingZip;
            billingAddress.StateRegion = checkoutState.BillingState;
            billingAddress.Country = checkoutState.BillingCountry;
            billingAddress.Phone = checkoutState.BillingPhoneNumber;
            billingAddress.Email = checkoutState.BillingEmail;
            billingAddress.Company = checkoutState.BillingCompany;

            return billingAddress;
        }
        internal static CartAddress GetBillingAddressFromCheckoutState(OrdersManager ordersManager, CheckoutState checkoutState)
        {
            CartAddress billingAddress = ordersManager.CreateCartAddress();

            billingAddress.FirstName   = checkoutState.BillingFirstName;
            billingAddress.LastName    = checkoutState.BillingLastName;
            billingAddress.Email       = checkoutState.BillingEmail;
            billingAddress.Address     = checkoutState.BillingAddress1;
            billingAddress.Address2    = checkoutState.BillingAddress2;
            billingAddress.AddressType = AddressType.Billing;
            billingAddress.City        = checkoutState.BillingCity;
            billingAddress.PostalCode  = checkoutState.BillingZip;
            billingAddress.StateRegion = checkoutState.BillingState;
            billingAddress.Country     = checkoutState.BillingCountry;
            billingAddress.Phone       = checkoutState.BillingPhoneNumber;
            billingAddress.Email       = checkoutState.BillingEmail;
            billingAddress.Company     = checkoutState.BillingCompany;

            return(billingAddress);
        }
Пример #3
0
        private static void UpdateCartDetails(CheckoutState checkoutState, OrdersManager ordersManager, Customer customer, CartOrder cartOrder)
        {
            CartAddress shippingAddress = null;

            if (checkoutState.OrderRequiresShipping)
            {
                shippingAddress             = ordersManager.CreateCartAddress();
                shippingAddress.FirstName   = checkoutState.ShippingFirstName;
                shippingAddress.LastName    = checkoutState.ShippingLastName;
                shippingAddress.Address     = checkoutState.ShippingAddress1;
                shippingAddress.Address2    = checkoutState.ShippingAddress2;
                shippingAddress.AddressType = AddressType.Shipping;
                shippingAddress.City        = checkoutState.ShippingCity;
                shippingAddress.PostalCode  = checkoutState.ShippingZip;
                shippingAddress.StateRegion = checkoutState.ShippingState;
                shippingAddress.Country     = checkoutState.ShippingCountry;
                shippingAddress.Phone       = checkoutState.ShippingPhoneNumber;
                shippingAddress.Email       = checkoutState.ShippingEmail;
                shippingAddress.Company     = checkoutState.ShippingCompany;
                shippingAddress.County      = checkoutState.ShippingCounty;
                cartOrder.Addresses.Add(shippingAddress);
            }

            var billingAddress = ordersManager.CreateCartAddress();

            billingAddress.FirstName   = checkoutState.BillingFirstName;
            billingAddress.LastName    = checkoutState.BillingLastName;
            billingAddress.Address     = checkoutState.BillingAddress1;
            billingAddress.Address2    = checkoutState.BillingAddress2;
            billingAddress.AddressType = AddressType.Billing;
            billingAddress.City        = checkoutState.BillingCity;
            billingAddress.PostalCode  = checkoutState.BillingZip;
            billingAddress.StateRegion = checkoutState.BillingState;
            billingAddress.Country     = checkoutState.BillingCountry;
            billingAddress.Phone       = checkoutState.BillingPhoneNumber;
            billingAddress.Email       = checkoutState.BillingEmail;
            billingAddress.Company     = checkoutState.BillingCompany;
            billingAddress.County      = checkoutState.BillingCounty;

            cartOrder.Addresses.Add(billingAddress);

            decimal vatTaxAmount = cartOrder.VatTaxAmount.HasValue ? cartOrder.VatTaxAmount.Value : 0;

            checkoutState.SubTotal        = cartOrder.SubTotalDisplay + vatTaxAmount;
            checkoutState.TotalWeight     = cartOrder.Weight;
            checkoutState.Tax             = cartOrder.Tax;
            checkoutState.ShippingAmount  = cartOrder.ShippingTotal;
            checkoutState.ShippingTax     = cartOrder.ShippingTax;
            checkoutState.ShippingTaxRate = cartOrder.ShippingTaxRate;
            checkoutState.DiscountAmount  = cartOrder.DiscountTotal;
            checkoutState.Total           = cartOrder.Total;

            var paymentmethod = ordersManager.GetPaymentMethods().FirstOrDefault();

            checkoutState.PaymentMethodId   = paymentmethod.Id;
            checkoutState.PaymentMethodType = paymentmethod.PaymentMethodType;

            CartPayment cartPayment = ordersManager.CreateCartPayment();

            cartPayment.PaymentMethodId        = paymentmethod.Id;
            cartPayment.PaymentMethodType      = paymentmethod.PaymentMethodType;
            cartPayment.CreditCardCustomerName = customer.CustomerFirstName;
            cartPayment.CreditCardNumber       = MockCreditCardNumber;

            cartOrder.Payments.Add(cartPayment);
        }