/// <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> /// <param name="carrierPickup"> /// The <carrier-pickup> tag specifies how the package will be /// transferred from the merchant to the shipper. Valid values for this /// tag are REGULAR_PICKUP, SPECIAL_PICKUP and DROP_OFF. The default /// value for this tag is DROP_OFF. /// </param> /// <param name="additionalFixedCharge"> /// The <additional-fixed-charge> tag allows you to specify a fixed /// charge that will be added to the total cost of an order if the buyer /// selects the associated shipping option. If you also adjust the /// calculated shipping cost using the /// <additional-variable-charge-percent> tag, the fixed charge will /// be added to the adjusted shipping rate. /// </param> /// <param name="additionalVariableChargePercent"> /// The <additional-variable-charge-percent> tag specifies a /// percentage amount by which a carrier-calculated shipping rate will be /// adjusted. The tag's value may be positive or negative. For example, if /// the tag's value is 15, then the carrier's shipping rate will /// effectively be multiplied by 1.15 to determine the shipping cost /// presented to the buyer. So, if the carrier shipping rate were $10.00, /// the adjusted shipping rate would be $11.50 – i.e. $10.00 + /// ($10.00 X 15%). If the <additional-variable-charge-percent> tag /// value is negative, the calculated shipping rate will be discounted by /// the specified percentage. /// </param> /// <returns></returns> public CarrierCalculatedShippingOption AddShippingOption( ShippingType shippingType, decimal defaultValue, CarrierPickup carrierPickup, decimal additionalFixedCharge, double additionalVariableChargePercent) { //CarrierCalculatedShippingOption verifies the fractional cents //call the default Add to perform the validation CarrierCalculatedShippingOption retVal = AddShippingOption(shippingType, defaultValue); additionalFixedCharge = Math.Round(additionalFixedCharge, 2); retVal.CarrierPickup = carrierPickup; retVal.AdditionalFixedCharge = additionalFixedCharge; if (additionalVariableChargePercent != 0) { retVal.AdditionalVariableChargePercent = additionalVariableChargePercent; } 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; }