My favorites | English | Sign in

Google Checkout

HTML API - Rounding Policy

Note: This is the latest documentation. The previous version of this page is identical — only the left nav differs.

For all financial calculations, Google Checkout uses a default rounding policy that is selected based on the merchant's home country.

  • For U.S. merchants, Google Checkout uses banker's rounding as its default policy. Banker's rounding is the same as the traditional method of rounding numbers with one exception. In banker's rounding, if the number to be rounded is followed by a five and no additional nonzero digits, the number is rounded to the nearest even number. The following examples demonstrate the expected behavior in banker's rounding:

    • 12.435 would be rounded up to 12.44. The number to be rounded (3) is rounded to the nearest even digit (4).
    • 12.445 would be rounded down to 12.44. The number to be rounded (4) is not rounded because it is an even digit.
    • 12.44501 would be rounded up to 12.45. The number to be rounded (4) is followed by a five and by additional nonzero digits.

    For U.S. merchants, Google calculates the total amount of tax for all of the items in an order and then uses banker's rounding to round that amount to two decimal places.

  • For U.K. merchants, Google Checkout uses the HALF_UP rounding mode. For this rounding mode, if the number being rounded is followed by a five and no additional nonzero digits, then that number is rounded up. All other numbers are rounded to the nearest digit. The following examples demonstrate the expected behavior for HALF_UP rounding:

    • 12.434 would be rounded down to 12.43.
    • 12.435 would be rounded up to 12.44.
    • 12.445 would be rounded up to 12.45.
    • 12.456 would be rounded up to 12.46.

    For U.K. merchants, Google calculates tax for each item in the order and then uses HALF_UP rounding for each calculated amount.

To specify a different rounding policy, you must add the mode and rule parameters to your Checkout API request.

The example below illustrates how these parameters would appear in a Checkout API request:

<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.rounding-policy.mode"
  value="HALF_UP"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.rounding-policy.rule"
  value="PER_LINE"/>

The list below explains the mode and rule parameters.

  • The mode parameter allows you to specify the methodology that will be used to round values to two decimal places. This tag may contain any of the following values, each of which is defined in the Java 1.5 specification for the RoundingMode enumeration.

    • UP - This mode rounds numbers away from zero. For example, the number 1.111 would be rounded to 1.12.

    • DOWN - This mode rounds numbers toward zero. For example, the number 1.666 would be rounded to 1.66.

    • CEILING - This mode rounds numbers toward positive infinity. For positive numbers, the CEILING mode functions identically to the UP rounding mode. For negative numbers, the CEILING mode functions identically to the DOWN rounding mode.

    • HALF_UP - This mode rounds numbers to the nearest digit. However, if the number being rounded is followed by a five and no additional nonzero digits, then then that number will be rounded up. For example, the number 1.165 would be rounded to 1.17. This method is the default rounding mode for U.K. merchants.

    • HALF_DOWN - This mode rounds numbers to the nearest digit. However, if the number being rounded is followed by a five and no additional nonzero digits, then then that number will be rounded down. For example, the number 1.165 would be rounded to 1.16.

    • HALF_EVEN - This mode, which is also known as banker's rounding, is the default rounding mode for U.S. merchants. Banker's rounding is the same as the traditional method of rounding numbers with one exception. In banker's rounding, if the number to be rounded is followed by a five and no additional nonzero digits, the number is rounded to the nearest even number.

  • The rule parameter specifies when rounding rules should be applied to monetary values while Google Checkout is computing an order total. This parameter may contain either of the following values:

    • PER_LINE - This rounding rule indicates that Google should calculate the tax for each line item and round each of those tax values using the specified rounding mode. After each tax value has been rounded, Google should then add the tax values to determine the total tax. In addition, the rounded tax value for each item is added back to the item price for display. This is the default rounding rule for U.K. merchants.

      Note: A line item is comprised of one or more units of the same item. For example, if a shopping cart contains two identical items that each cost $1.00 and the sales tax rate is 7.5 percent, then the total cost of the line item is $2.00 and the total tax for the line item is 15 cents.

    • TOTAL - This rounding rule indicates that Google should calculate the tax for each item and add those tax values to calculate the total unrounded tax amount for the order. Google should then apply the specified rounding mode to the total tax to determine the total tax for the order. This is the default rounding rule for U.S. merchants.

HTML Parameter Definitions

mode

The <mode> parameter specifies the method that will be used to round monetary values to two decimal places. This parameter may contain any of the following values, each of which is defined in the Java 1.5 specification for the RoundingMode enumeration.RoundingMode enumeration.

  • UP - This mode rounds numbers away from zero. For example, the number 1.111 would be rounded to 1.12.

  • DOWN - This mode rounds numbers toward zero. For example, the number 1.666 would be rounded to 1.66.

  • CEILING - This mode rounds numbers toward positive infinity. For positive numbers, the CEILING mode functions identically to the UP rounding mode. For negative numbers, the CEILING mode functions identically to the DOWN rounding mode.

  • HALF_UP - This mode rounds numbers to the nearest digit. However, if the number being rounded is followed by a five and no additional nonzero digits, then then that number will be rounded up. For example, the number 1.165 would be rounded to 1.17. This method is the default rounding mode for U.K. merchants.

  • HALF_DOWN - This mode rounds numbers to the nearest digit. However, if the number being rounded is followed by a five and no additional nonzero digits, then then that number will be rounded down. For example, the number 1.165 would be rounded to 1.16.

  • HALF_EVEN - This mode, which is also known as banker's rounding, is the default rounding mode for U.S. merchants. Banker's rounding is the same as the traditional method of rounding numbers with one exception. In banker's rounding, if the number to be rounded is followed by a five and no additional nonzero digits, the number is rounded to the nearest even number.

API commands


Content format for parameter value


String

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.rounding-policy.mode" value="HALF_UP"/>

rule

The <rule> parameter indicates when the rounding rule will be applied. Valid values for this parameter are PER_LINE and TOTAL. For U.S. merchants, the default value for this parameter is TOTAL. For U.K. merchants, the default value for this parameter is PER_LINE. The following list explains the meaning of these two values:

  • PER_LINE - This rounding rule indicates that Google should calculate the tax for each line item and round each of those tax values using the specified rounding mode. After each tax value has been rounded, Google should then add the tax values to determine the total tax.

    Note: A line item is comprised of one or more units of the same item. For example, if a shopping cart contains two identical items that each cost $1.00 and the sales tax rate is 7.5 percent, then the total cost of the line item is $2.00 and the total tax for the line item is 15 cents.

  • TOTAL - This rounding rule indicates that Google should calculate the tax for each item and add those tax values to calculate the total unrounded tax amount for the order. Google should then apply the specified rounding mode to the total tax to determine the total tax for the order.

API commands


Content format for parameter value


String

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.rounding-policy.rule" value="PER_LINE"/>