/// <summary> /// Create a new Carrier Calculated Shipping Option with the minimum /// Amount of information needed. /// </summary> /// <param name="shippingType">The Shipping Type to add /// (This must be unique)</param> /// <param name="defaultValue">The default cost for the shipping option. /// The default cost will be assessed if Google's attempt to obtain the /// carrier's shipping rates fails for any reason.</param> /// <returns></returns> public CarrierCalculatedShippingOption AddShippingOption( ShippingType shippingType, decimal defaultValue) { //CarrierCalculatedShippingOption verifies the fractional cents if (_shippingNode == null) { //don't add it until we make sure we can use it. GCheckout.AutoGen.CarrierCalculatedShipping cs = new GCheckout.AutoGen.CarrierCalculatedShipping(); cs.carriercalculatedshippingoptions = new GCheckout.AutoGen.CarrierCalculatedShippingOption[] {}; //This will blow up if the type is not allowed. _request.VerifyShippingMethods(cs); _shippingNode = cs; _request.AddNewShippingMethod(cs); } if (_shippingOptions.ContainsKey(shippingType)) { throw new ApplicationException( string.Format("The carrier option {0} already exists.")); } CarrierCalculatedShippingOption retVal = new CarrierCalculatedShippingOption(_request._Currency, shippingType, defaultValue); //we need to copy the array and add an item to the end of the array //we would modify the xsd to be lists but it would most likely //confuse people. GCheckout.AutoGen.CarrierCalculatedShippingOption[] newArray = new GCheckout.AutoGen.CarrierCalculatedShippingOption[ ShippingOptionsCount + 1 ]; Array.Copy(_shippingNode.carriercalculatedshippingoptions, newArray, ShippingOptionsCount); newArray[newArray.Length - 1] = retVal.ShippingOption; _shippingNode.carriercalculatedshippingoptions = newArray; _shippingOptions.Add(shippingType, retVal); Sync(); return(retVal); }
/// <summary> /// Create a new Carrier Calculated Shipping Option with the minimum /// Amount of information needed. /// </summary> /// <param name="shippingType">The Shipping Type to add /// (This must be unique)</param> /// <param name="defaultValue">The default cost for the shipping option. /// The default cost will be assessed if Google's attempt to obtain the /// carrier's shipping rates fails for any reason.</param> /// <returns></returns> public CarrierCalculatedShippingOption AddShippingOption( ShippingType shippingType, decimal defaultValue) { //CarrierCalculatedShippingOption verifies the fractional cents if (_shippingNode == null) { //don't add it until we make sure we can use it. GCheckout.AutoGen.CarrierCalculatedShipping cs = new GCheckout.AutoGen.CarrierCalculatedShipping(); cs.carriercalculatedshippingoptions = new GCheckout.AutoGen.CarrierCalculatedShippingOption[] {}; //This will blow up if the type is not allowed. _request.VerifyShippingMethods(cs); _shippingNode = cs; _request.AddNewShippingMethod(cs); } if (_shippingOptions.ContainsKey(shippingType)) throw new ApplicationException( string.Format("The carrier option {0} already exists.")); CarrierCalculatedShippingOption retVal = new CarrierCalculatedShippingOption(_request._Currency, shippingType, defaultValue); //we need to copy the array and add an item to the end of the array //we would modify the xsd to be lists but it would most likely //confuse people. GCheckout.AutoGen.CarrierCalculatedShippingOption[] newArray = new GCheckout.AutoGen.CarrierCalculatedShippingOption[ ShippingOptionsCount + 1 ]; Array.Copy(_shippingNode.carriercalculatedshippingoptions, newArray, ShippingOptionsCount); newArray[newArray.Length - 1] = retVal.ShippingOption; _shippingNode.carriercalculatedshippingoptions = newArray; _shippingOptions.Add(shippingType, retVal); Sync(); return retVal; }