/// <summary>Retrieves all the current Payment choices from the user</summary>
        /// <param name="shippingAddress">dunno</param>
        /// <returns>The list of Payments to submit for the order</returns>
        public List <Payment> GetPayments(Address_V01 shippingAddress)
        {
            var paymentList = new List <Payment>();
            var choice      = GetCurrentPaymentOption();

            switch (choice)
            {
            case PaymentOptionChoice.DirectDeposit:
            case PaymentOptionChoice.WireTransfer:
            case PaymentOptionChoice.PaymentGateway:
            {
                paymentList.Add(CreateDummyPayment(shippingAddress));
                break;
            }

            case PaymentOptionChoice.CreditCard:
            {
                paymentList =
                    new List <Payment>(
                        (from p in GetPaymentInformation()
                         where !string.IsNullOrEmpty(p.AuthorizationCode)
                         select p as Payment).ToList());
                break;
            }
            }

            string currentKey = PaymentsConfiguration.GetCurrentPaymentSessionKey(_locale, _distributorId);

            Session[currentKey] = paymentList;
            return(paymentList);
        }
Beispiel #2
0
        private string getLine1(Address_V01 address)
        {
            string Line1 = string.Empty;

            if (address != null && !string.IsNullOrEmpty(address.Line4))
            {
                var streets = address.Line4.Split(new[] { "%%%" }, StringSplitOptions.RemoveEmptyEntries);
                if (streets.Length > 0)
                {
                    Line1 = streets[0];
                    if (!string.IsNullOrEmpty(address.Line3))
                    {
                        Line1 = string.Format("{0}, {1}", Line1, address.Line3);
                    }
                    if (streets.Length > 1)
                    {
                        Line1 = Line1 + ", " + streets[1];
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(address.Line3))
                    {
                        Line1 = address.Line1 + ", " + address.Line3;
                    }
                }
            }
            return(Line1);
        }
Beispiel #3
0
        public override object CreateAddressFromControl(string typeName)
        {
            object dataContext = DataContext;
            var    shipping    = new ShippingAddress_V02();

            if (dataContext != null)
            {
                shipping = (ShippingAddress_V02)dataContext;
            }
            var shippingAddress = new Address_V01();

            shippingAddress.Line1 = string.Concat(txtStreet.Text, " ", txtStreet2.Text).Trim();
            shippingAddress.Line2 = txtNeighborhood.Text;
            shippingAddress.Line3 = StreetNumber;
            shippingAddress.Line4 = string.Concat(txtStreet.Text, "%%%", txtStreet2.Text);

            shippingAddress.City                   = City;
            shippingAddress.CountyDistrict         = County ?? string.Empty;
            shippingAddress.StateProvinceTerritory = StateProvince;
            shippingAddress.PostalCode             = ZipCode;
            shipping.Address   = shippingAddress;
            shipping.Phone     = PhoneNumber;
            shipping.AreaCode  = AreaCode;
            shipping.Recipient = Recipient;

            return(_shippingAddr = shipping);
        }
Beispiel #4
0
        public virtual object CreateAddressFromControl(string typeName)
        {
            object dataContext = DataContext;
            var    shipping    = new ShippingAddress_V02();

            if (dataContext != null)
            {
                shipping = (ShippingAddress_V02)dataContext;
            }
            var shippingAddress = new Address_V01();

            shippingAddress.Line1 = StreetAddress ?? string.Empty;
            shippingAddress.Line2 = StreetAddress2 ?? string.Empty;
            shippingAddress.Line3 = StreetAddress3 ?? string.Empty;
            shippingAddress.Line4 = StreetAddress4 ?? string.Empty;

            shippingAddress.City                   = City;
            shippingAddress.CountyDistrict         = County ?? string.Empty;
            shippingAddress.StateProvinceTerritory = StateProvince;
            shippingAddress.PostalCode             = ZipCode;
            shipping.Address     = shippingAddress;
            shipping.Phone       = PhoneNumber;
            shipping.AltAreaCode = Extension ?? string.Empty;
            shipping.AreaCode    = AreaCode ?? string.Empty;
            shipping.Recipient   = Recipient;
            return(_shippingAddr = shipping);
        }
        //public override bool IsPickupInstructionsRequired() { return true; }

        public override bool ShouldRecalculate(string oldFreightCode,
                                               string newFreightCode,
                                               Address_V01 oldaddress,
                                               Address_V01 newaddress)
        {
            return(false);
        }
        protected override bool IsValidShippingAddress(Address_V01 a)
        {
            if (string.IsNullOrWhiteSpace(a.StateProvinceTerritory) ||
                string.IsNullOrWhiteSpace(a.City) ||
                string.IsNullOrWhiteSpace(a.CountyDistrict))
            {
                // fails when City or County are empty
                return(false);
            }

            if (a.PostalCode != null && a.PostalCode.Length > 0 && a.PostalCode.Length != 5)
            {
                // postal code is optional but when present, it MUST be 5 chars long
                return(false);
            }

            if (!GetStatesForCountry(a.Country).Contains(a.StateProvinceTerritory) ||
                !GetCitiesForState(a.Country, a.StateProvinceTerritory).Contains(a.City) ||
                !GetCountiesForCity(a.Country, a.StateProvinceTerritory, a.City).Contains(a.CountyDistrict))
            {
                // finally, validate that city and county are within valid set of values
                return(false);
            }

            return(true);
        }
Beispiel #7
0
        public bool ValidateAddress(Address_V01 address, out Address_V01 avsOutputAddress)
        {
            ServiceProvider.AddressValidationSvc.Address avsAddress = null;
            var errorCode = string.Empty;
            var isValid   =
                new ShippingProvider_US().ValidateAddress(new ShippingAddress_V02(0, string.Empty, string.Empty,
                                                                                  string.Empty, string.Empty, address, string.Empty, string.Empty, true, string.Empty, DateTime.Now),
                                                          out errorCode, out avsAddress);

            if (isValid && null != avsAddress && !CheckAvsAddressForNull(avsAddress))
            {
                avsOutputAddress = new Address_V01
                {
                    City                   = avsAddress.City,
                    Country                = avsAddress.CountryCode,
                    CountyDistrict         = avsAddress.CountyDistrict,
                    Line1                  = avsAddress.Line1,
                    Line2                  = avsAddress.Line2,
                    Line3                  = avsAddress.Line3,
                    Line4                  = avsAddress.Line4,
                    PostalCode             = avsAddress.PostalCode,
                    StateProvinceTerritory = avsAddress.StateProvinceTerritory
                };
                return(true);
            }
            avsOutputAddress = null;
            return(false);
        }
Beispiel #8
0
        public bool ValidateAddress(Address_V01 address, out Address_V01 avsOutputAddress)
        {
            bool isValid = _shippingProvider.ValidatePostalCode(address.Country, address.StateProvinceTerritory,
                                                                address.City, address.PostalCode);

            avsOutputAddress = address;
            return(isValid);
        }
 public ShippingAddress_V02(int id, string recipient, string firstName, string lastName, string middleName,
                            Address_V01 address, string phone, string altphone, bool isPrimary, string alias, DateTime created)
     : base(id, recipient, address, phone, altphone, isPrimary, alias, created)
 {
     this.FirstName  = firstName;
     this.LastName   = lastName;
     this.MiddleName = middleName;
 }
Beispiel #10
0
        public override DeliveryOption GetDefaultAddress()
        {
            Address_V01 address = new Address_V01();

            address.City = "Bolivia";
            return(new DeliveryOption(new ShippingAddress_V02()
            {
                ID = 0, Recipient = string.Empty, FirstName = string.Empty, MiddleName = string.Empty, LastName = string.Empty, Address = address, Phone = "", AltPhone = "", IsPrimary = false, Alias = "", Created = DateTime.Now
            }));
        }
 protected override bool IsValidShippingAddress(Address_V01 a)
 {
     if ((string.IsNullOrWhiteSpace(a.PostalCode)) && (GetStatesForCountry(a.Country).Contains(a.StateProvinceTerritory)) && (GetCitiesForState(a.Country, a.StateProvinceTerritory).Contains(a.City)))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private Object GetAddress(Address_V01 address)
        {
            var stringList = new List <string>();

            if (address != null)
            {
                stringList.Add(address.Line1);
                stringList.Add(string.Format("{0}, {1} {2}", address.City, address.StateProvinceTerritory, address.PostalCode));
            }
            return(stringList);
        }
        private void FetchPickupLocations()
        {
            ShippingAddress_V02 address    = new ShippingAddress_V02();
            Address_V01         addressV01 = new Address_V01();

            addressV01.Country = (this.Page as ProductsBase).CountryCode;
            address.Address    = addressV01;

            PickupLocations = (this.Page as ProductsBase).
                              GetShippingProvider().GetDeliveryOptions(DeliveryOptionType.Pickup, address);
        }
Beispiel #14
0
 public override bool ShouldRecalculate(string oldFreightCode,
                                        string newFreightCode,
                                        Address_V01 oldaddress,
                                        Address_V01 newaddress)
 {
     if (oldaddress == null || newaddress == null)
     {
         return(true);
     }
     return(oldaddress.Line3 != newaddress.Line3);
 }
Beispiel #15
0
        protected Object GetAddress(Address_V01 address)
        {
            var stringList = new List <string>();

            if (address != null)
            {
                stringList.Add(address.Line1);
                stringList.Add(address.Line2);
                stringList.Add(address.City + "," + address.StateProvinceTerritory);
            }
            return(stringList);
        }
        private void PopulatePickupInfoDataList()
        {
            Providers.Interfaces.IShippingProvider provider = null;
            if (Thread.CurrentThread.CurrentCulture.Name == "es-MX")
            {
                provider = ProductsBase.GetShippingProvider() as ShippingProvider_MX;
            }
            else if (Thread.CurrentThread.CurrentCulture.Name == "es-AR")
            {
                provider = ProductsBase.GetShippingProvider() as ShippingProvider_AR;
            }

            if (provider != null)
            {
                var shippingAddress = new ShippingAddress_V02();
                var address         = new Address_V01();
                address.PostalCode      = ViewState["PostalCode"].ToString();
                shippingAddress.Address = address;

                List <DeliveryOption> pickupOptions = provider.GetDeliveryOptions(DeliveryOptionType.Pickup,
                                                                                  shippingAddress);
                if (pickupOptions != null)
                {
                    divLocations.Visible    = true;
                    dlPickupInfo.DataSource =
                        (
                            from o in pickupOptions
                            orderby o.Description
                            select new
                    {
                        ID = o.Id,
                        IsPickup = true,
                        Description = new Func <string>(() =>
                        {
                            GetImage(o.Description.ToUpper());
                            return(o.Description.ToUpper().ToString());
                        })(),
                        BranchName = o.Name,
                        o.FreightCode,
                        Warehouse = o.WarehouseCode,
                        o.Address
                    }
                        );

                    dlPickupInfo.DataBind();
                }

                if (pickupOptions.Count.Equals(0))
                {
                    divLocations.Visible = false;
                }
            }
        }
Beispiel #17
0
 public override bool ShouldRecalculate(string oldFreightCode,
                                        string newFreightCode,
                                        Address_V01 oldaddress,
                                        Address_V01 newaddress)
 {
     if (oldaddress == null || newaddress == null)
     {
         return(true);
     }
     return(oldaddress.StateProvinceTerritory != newaddress.StateProvinceTerritory ||
            oldFreightCode != newFreightCode);
 }
 public override string[] GetFreightCodeAndWarehouseForTaxRate(Address_V01 address)
 {
     if (address != null)
     {
         return(new[]
         {
             HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode,
             HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse
         });
     }
     return(null);
 }
 public ShippingAddress_V01(int id, string recipient, Address_V01 address, string phone, string altphone, bool isPrimary, string alias, DateTime created)
     : base(id)
 {
     ID        = id;
     Recipient = recipient;
     Address   = address;
     Phone     = phone;
     AreaCode  = AltAreaCode = AltPhone = string.Empty;
     IsPrimary = isPrimary;
     Alias     = alias;
     Created   = created;
     AltPhone  = altphone;
 }
Beispiel #20
0
 private Address_V01 validateAdressValues(Address_V01 address)
 {
     if (address != null)
     {
         address.Line1 = address.Line1 ?? string.Empty;
         address.Line2 = address.Line2 ?? string.Empty;
         address.Line3 = address.Line3 ?? string.Empty;
         address.Line4 = address.Line4 ?? string.Empty;
         address.City  = address.City ?? string.Empty;
         address.StateProvinceTerritory = address.StateProvinceTerritory ?? string.Empty;
     }
     return(address);
 }
Beispiel #21
0
        /// <summary>
        /// Gets the list of postal officess cities for a state.
        /// </summary>
        /// <param name="Country">The country code.</param>
        /// <param name="State">The state code.</param>
        /// <returns>The list of city names.</returns>
        public override List <string> GetCitiesForState(string Country, string State)
        {
            var addressV1 = new Address_V01 {
                Country = Country, StateProvinceTerritory = State
            };
            var address = new ShippingAddress_V01 {
                Address = addressV1
            };
            var deliveryOptions = GetDeliveryOptionsFromCache(address);

            var cities = (from p in deliveryOptions
                          select p.Address.City).Distinct().OrderBy(s => s).ToList();

            return(cities);
        }
        public static Address_V01 CreateDefaultAddress()
        {
            var address = new Address_V01();

            address.Country                = "CN";
            address.Line1                  = "中路268号4801室";
            address.Line2                  = "";
            address.Line3                  = "";
            address.Line4                  = "";
            address.City                   = "西藏";
            address.PostalCode             = "200001";
            address.StateProvinceTerritory = "上海市";
            address.CountyDistrict         = "黄埔区";
            return(address);
        }
Beispiel #23
0
        /// <summary>
        /// Gets the list of postal officess neighbourhoods for a city.
        /// </summary>
        /// <param name="country">The country code.</param>
        /// <param name="state">The state name.</param>
        /// <param name="city">The city name.</param>
        /// <returns>The neighbourhood names.</returns>
        public List <string> GetNeighbourhoodForCity(string country, string state, string city)
        {
            var addressV1 = new Address_V01 {
                Country = country, StateProvinceTerritory = state, City = city
            };
            var address = new ShippingAddress_V01 {
                Address = addressV1
            };
            var deliveryOptions = GetDeliveryOptionsFromCache(address);

            var neighbourhoods = (from p in deliveryOptions
                                  select p.Address.Line3).Distinct().OrderBy(s => s).ToList();

            return(neighbourhoods);
        }
        public bool ValidateAndGetPayments(Address_V01 shippingAddress, out List <Payment> payments, bool showErrors)
        {
            bool isValid = true;

            payments = new List <Payment>();
            var currentPayments = GetPayments(shippingAddress);
            var orderTotals     = GetTotals();

            if (isValid)
            {
                decimal total = (from c in currentPayments select c.Amount).Sum();
                if (total != orderTotals.AmountDue)
                {
                    isValid = false;
                    if (total > 0)
                    {
                        if (showErrors)
                        {
                            lblErrorMessages.Text = PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                              "TotalNotMatch");
                        }
                        totalAmountBalance.Text = DisplayAsCurrency(orderTotals.AmountDue - total, false);
                    }
                    else
                    {
                        if (showErrors)
                        {
                            lblErrorMessages.Text = PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                              "NoPaymentInfo");
                        }
                    }
                }
            }

            if (isValid)
            {
                payments = currentPayments;
            }

            _paymentError = !isValid;

            if (showErrors && _paymentError)
            {
                OnCardAddOrEdit(null, null);
            }
            return(isValid);
        }
 public override bool ShouldRecalculate(string oldFreightCode,
                                        string newFreightCode,
                                        Address_V01 oldaddress,
                                        Address_V01 newaddress)
 {
     if (oldFreightCode != newFreightCode)
     {
         return(true);
     }
     if (oldaddress == null || newaddress == null ||
         (!string.IsNullOrEmpty(oldaddress.PostalCode) && !string.IsNullOrEmpty(newaddress.PostalCode) &&
          !oldaddress.PostalCode.Equals(newaddress.PostalCode)))
     {
         return(true);
     }
     return(false);
 }
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string country, string locale, ShippingAddress_V01 address)
        {
            List <DeliveryOption>           deliveryOptions = new List <DeliveryOption>();
            CityBoxAlternativesResponse_V01 response        = null;

            var proxy = ServiceClientProvider.GetShippingServiceProxy();

            response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(new GetCityBoxRequest_V01()
            {
                Country = "CL", FreightCode = FreightCode_CityBox, Warehouse = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse.ToString(), Locale = "es-CL"
            })).GetDeliveryOptionsResult as CityBoxAlternativesResponse_V01;
            DeliveryOption dlv;
            Address_V01    add;

            if (response != null && response.DeliveryAlternatives != null)
            {
                foreach (var location in response.DeliveryAlternatives)
                {
                    add = new Address_V01()
                    {
                        City                   = location.City,
                        Country                = location.Country,
                        CountyDistrict         = location.CountyDistrict,
                        Line1                  = location.LocationDescription,
                        Line2                  = "",
                        Line3                  = location.Line1,
                        Line4                  = location.Line2,
                        PostalCode             = location.PostalCode,
                        StateProvinceTerritory = location.StateProvinceTerritory
                    };
                    int id = location.ID;
                    dlv =
                        new DeliveryOption(new ShippingAddress_V02()
                    {
                        ID       = id, Recipient = location.LocationDescription, FirstName = string.Empty,
                        LastName = string.Empty, MiddleName = string.Empty, Address = add, Phone = "", AltPhone = "", IsPrimary = false,
                        Alias    = location.LocationDescription, Created = DateTime.Now
                    });
                    dlv.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse;
                    dlv.FreightCode   = FreightCode_CityBox;
                    deliveryOptions.Add(dlv);
                }
            }
            return(deliveryOptions);
        }
        protected override bool IsValidShippingAddress(Address_V01 a)
        {
            if (string.IsNullOrWhiteSpace(a.StateProvinceTerritory) ||
                string.IsNullOrWhiteSpace(a.City))
            {
                // fails when State or County are empty (they're required)
                return(false);
            }

            if (!GetStatesForCountry(a.Country).Contains(a.StateProvinceTerritory) ||
                !GetCitiesForState(a.Country, a.StateProvinceTerritory).Contains(a.City))
            {
                // finally, validate that State and City are within valid set of values
                return(false);
            }

            return(true);
        }
Beispiel #28
0
        public override string GetFreightVariant(ShippingInfo shippingInfo)
        {
            if (shippingInfo != null && shippingInfo.Option == DeliveryOptionType.Shipping)
            {
                if (shippingInfo.FreightCode.Equals(HLConfigManager.Configurations.APFConfiguration.APFFreightCode))
                {
                    return(null);
                }

                Address_V01 address = shippingInfo != null && shippingInfo.Address != null
                                          ? shippingInfo.Address.Address
                                          : null;
                if (address != null)
                {
                    return(address.Line3 == null ? "YO" : address.Line3);
                }
            }
            return(null);
        }
Beispiel #29
0
        protected override bool IsValidShippingAddress(Address_V01 a)
        {
            AddressFieldForCountryRequest_V01 request = new AddressFieldForCountryRequest_V01()
            {
                AddressField = AddressPart.ZIPCODE,
                Country      = a.Country,
                State        = a.StateProvinceTerritory,
                City         = a.City
            };
            List <string> lookupResults = GetAddressField(request);

            if ((!string.IsNullOrWhiteSpace(a.PostalCode)) && (GetStatesForCountry(a.Country).Contains(a.StateProvinceTerritory)) && (GetCitiesForState(a.Country, a.StateProvinceTerritory).Contains(a.City)) && (lookupResults.Contains(a.PostalCode)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #30
0
        /// <summary>
        /// Format the address object to send to HMS
        /// </summary>
        /// <param name="address">The address</param>
        /// <returns></returns>
        public override bool FormatAddressForHMS(MyHerbalife3.Ordering.ServiceProvider.SubmitOrderBTSvc.Address address)
        {
            var addrV01 = new Address_V01()
            {
                Line1 = address.Line1,
                Line2 = address.Line2,
                City  = address.City,
                StateProvinceTerritory = address.StateProvinceTerritory,
                CountyDistrict         = address.CountyDistrict,
                Country = address.Country
            };

            if (address != null && !string.IsNullOrEmpty(address.StateProvinceTerritory) &&
                !string.IsNullOrEmpty(address.City) &&
                !IsValidShippingAddress(addrV01))   //apply this when using OLD Address FORMAT
            {
                address.City = string.Format("{0}, {1}", address.City, address.StateProvinceTerritory);
                address.StateProvinceTerritory = string.Empty;
            }
            return(true);
        }