/// <summary> /// Add a Ship Address For Calculated Shipping /// </summary> /// <param name="shipFromId">The ID of the Ship From</param> /// <param name="city"> /// The <city> tag identifies the city associated with a /// shipping adrress /// </param> /// <param name="region"> /// The <region> tag identifies the state or province associated /// with a shipping address. /// </param> /// <param name="postalCode"> /// The <postal-code> tag identifies the zip code or postal code. /// </param> /// <param name="countryCode"> /// This tag contains the two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area. /// </param> /// <returns></returns> public ShippingPackage AddShippingPackage(string shipFromId, string city, string region, string postalCode, string countryCode) { if (_packages.Count > 0) { throw new ArgumentException("At this time, only one ShipFrom" + " address may be added."); } shipFromId = eh.CleanString(shipFromId); city = eh.CleanString(city); region = eh.CleanString(region); postalCode = eh.CleanString(postalCode); countryCode = eh.CleanString(countryCode); if (shipFromId.Length == 0 || city.Length == 0 || region.Length == 0 || postalCode.Length == 0 || countryCode.Length == 0) { throw new ArgumentNullException("All of the parameters are required."); } ShippingPackage retVal = new ShippingPackage(); retVal.ShippingLocation = new ShipFrom(shipFromId, city, region, postalCode, countryCode); _packages.Add(retVal); Sync(); return(retVal); }
/// <summary> /// Add a Ship Address For Calculated Shipping /// </summary> /// <param name="shipFromId">The ID of the Ship From</param> /// <param name="city"> /// The <city> tag identifies the city associated with a /// shipping adrress /// </param> /// <param name="region"> /// The <region> tag identifies the state or province associated /// with a shipping address. /// </param> /// <param name="postalCode"> /// The <postal-code> tag identifies the zip code or postal code. /// </param> /// <param name="countryCode"> /// This tag contains the two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area. /// </param> /// <param name="addressCategory"> /// The <delivery-address-category> tag indicates whether the shipping /// method should be applied to a residential or a commercial address. Valid /// values for this tag are RESIDENTIAL and COMMERCIAL. Please note that /// these names are case-sensitive. /// </param> /// <param name="height">The Height of the Package</param> /// <param name="length">The Length of the Package</param> /// <param name="width">The Width of the Package</param> /// <returns></returns> public ShippingPackage AddShippingPackage(string shipFromId, string city, string region, string postalCode, string countryCode, DeliveryAddressCategory addressCategory, int height, int length, int width) { ShippingPackage retVal = AddShippingPackage(shipFromId, city, region, postalCode, countryCode); retVal.AddressCategory = addressCategory; retVal.Height = height; retVal.Length = length; retVal.Width = width; return(retVal); }
private void Sync() { //now we want to add it to the node if (_shippingNode != null && _packages.Count > 0) { _shippingNode.shippingpackages = new AutoGen.ShippingPackage[_packages.Count]; for (int i = 0; i < _packages.Count; i++) { ShippingPackage package = _packages[i] as ShippingPackage; AutoGen.ShippingPackage sp = new GCheckout.AutoGen.ShippingPackage(); _shippingNode.shippingpackages[i] = sp; if (package.AddressCategory != DeliveryAddressCategory.UNKNOWN) { sp.deliveryaddresscategory = package.AddressCategory.ToString(); } if (package.Height > 0) { sp.height = GetDimension(package.Height); } if (package.Length > 0) { sp.length = GetDimension(package.Length); } ShipFrom sf = package.ShippingLocation; sp.shipfrom = new GCheckout.AutoGen.AnonymousAddress(); sp.shipfrom.city = sf.City; sp.shipfrom.countrycode = sf.CountryCode; sp.shipfrom.id = sf.ID; sp.shipfrom.postalcode = sf.PostalCode; sp.shipfrom.region = sf.Region; if (package.Width > 0) { sp.width = GetDimension(package.Width); } } } }
/// <summary> /// Add a Ship Address For Calculated Shipping /// </summary> /// <param name="shipFromId">The ID of the Ship From</param> /// <param name="city"> /// The <city> tag identifies the city associated with a /// shipping adrress /// </param> /// <param name="region"> /// The <region> tag identifies the state or province associated /// with a shipping address. /// </param> /// <param name="postalCode"> /// The <postal-code> tag identifies the zip code or postal code. /// </param> /// <param name="countryCode"> /// This tag contains the two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area. /// </param> /// <returns></returns> public ShippingPackage AddShippingPackage(string shipFromId, string city, string region, string postalCode, string countryCode) { if (_packages.Count > 0) { throw new ArgumentException("At this time, only one ShipFrom" + " address may be added."); } shipFromId = eh.CleanString(shipFromId); city = eh.CleanString(city); region = eh.CleanString(region); postalCode = eh.CleanString(postalCode); countryCode = eh.CleanString(countryCode); if (shipFromId.Length == 0 || city.Length == 0 || region.Length == 0 || postalCode.Length == 0 || countryCode.Length == 0) throw new ArgumentNullException("All of the parameters are required."); ShippingPackage retVal = new ShippingPackage(); retVal.ShippingLocation = new ShipFrom(shipFromId, city, region, postalCode, countryCode); _packages.Add(retVal); Sync(); return retVal; }