English | Site Directory

Google Checkout APIs

Google Checkout HTML API - Merchant-calculated Shipping

Overview
Understanding Merchant-calculated Shipping
Checklist for Implementing Merchant-calculated Shipping
HTML Examples for Merchant-Calculated Shipping
HTML Parameter Definitions

Overview

Merchant-calculated shipping allows you to wait until the buyer selects the shipping address for an order before you determine the availability and cost of different shipping options for that order.

Note: If you offer merchant-calculated shipping options for an order, you may not also provide other types of shipping options, including flat-rate, pickup or carrier-calculated options. In addition, even though you intend to calculate shipping costs, you must still specify a backup shipping cost for each merchant-calculated shipping option. If a merchant calculation fails for any reason, Google will use these backup values for the shipping methods in your order.

To use merchant-calculated shipping methods, you must build and operate a fast, highly reliable web service that calculates shipping costs. For more information about the process for calculating shipping costs for an order, please see the separate document titled Implementing the Merchant Calculations HTML API.

Understanding Merchant-calculated Shipping

To offer merchant-calculated shipping methods, you must include the following information in your Checkout API request:

  • The URL of your web service that calculates shipping costs. That service may also calculate taxes as well as price adjustments for coupons and gift certificates.

  • A list of merchant-calculated shipping options that are available for the order. For each option, Google strongly encourages you to provide the following information:

    • The default price for the shipping option. After the customer selects the shipping address for the order, Google will send a merchant-calculation-callback request to your calculations web service. If that request fails for any reason, Google will use the default price for the shipping option. If you do not provide a default price for a merchant-calculated shipping option, Google will not charge the customer for that option if the merchant-calculation-callback request fails.

    • A list of address filters, which restrict the shipping option so that it is only available for shipping addresses in specified geographic regions. For example, you could restrict a shipping option so that it is only available for shipping addresses in specific states or countries.

      You can also further restrict the availability of a shipping option only if a merchant-calculation-callback request fails. To add these additional constraints, your Checkout API request must specify shipping restrictions in addition to address filters. Please see the Address Filters and Shipping Restrictions section for more information about these two mechanisms.

Address Filters and Shipping Restrictions

Google Checkout provides two mechanisms, address filters and shipping restrictions, that allow you to restrict a shipping method so that it is only available for shipping addresses in specified geographic regions. You can allow customers to ship items (or prevent customers from shipping items) to specific states, zip codes or regions of the United States. You can also allow shipping to other countries or to the entire world. In addition, you can specify whether each shipping option is available if the shipping address is a U.S. post-office box. For more information about specifying geographic areas for shipping options or tax rules, please see the separate document that explains Checkout API HTML parameters for specifying geographic areas.

Google Checkout will allow your customer to select any shipping option where all of the following conditions are true:

  • The shipping address is included in the list of allowed areas for the shipping option.
  • The shipping address is not included in the list of excluded areas for the shipping option.
  • If the shipping address is a P.O. box, then the shipping option does not contain a shipping restriction specifying that the option cannot be selected to ship an order to a P.O. box. Please see the allow-us-po-box parameter definition for more information.

Note: Google Checkout's default behavior is to allow shipping to all postal addresses for the merchant's home country. For example, for U.S. merchants, Google Checkout default behavior is to allow shipping to all U.S. postal addresses, including military bases. As such, if you do not ship to all U.S. postal addresses, you do need to specify shipping restrictions in your Checkout API requests. For U.K. merchants, the default shipping area is all U.K. postal addresses.

Deciding to Use Shipping Restrictions or Address Filters

If you are implementing the Merchant Calculations API, then you may need to use either or both of these filtering mechanisms.

  • If a merchant-calculated shipping option is always available in the same areas, use address filters for that option. After the buyer selects a shipping address, Google Checkout will only display shipping options that are available after applying the address filters in your Checkout API request.

    Note: Most merchants only need to use address filters to limit the availability of merchant-calculated shipping options.

  • If you also want to limit the availability of a shipping option if a merchant-calculation-callback fails, then you must use shipping restrictions for that option. You can still use address filters for that shipping option if the option is only available in certain geographies.

    For example, suppose a merchant in the United States offers next-day shipping to addresses in the United States and England. However, the buyer can not select the next-day shipping option if the shipping address is a U.S. post-office (P.O.) box. In addition, if the shipping address is in England, the merchant only offers next-day shipping for orders placed by 12 p.m. EST.

    • The merchant in this example can use an address filter to prevent the buyer from selecting the shipping option if the shipping address is a P.O. box. The first bullet point in this section explains how to use address filters in this manner.

    • If the shipping address is in England, the merchant can choose whether to offer the next-day shipping option based on the time that the merchant receives the merchant-calculation-callback request for the order. However, if the shipping address is in England and the callback fails for any reason, then the merchant does not want to offer next-day shipping for the order. In this case, the merchant can use a shipping restriction to instruct Google not to offer the shipping option.

    If this example applies to you, meaning you need to limit the availability of shipping options when merchant-calculation-callback requests fail, please see the Shipping Restrictions and Address Filters document for more information about these features.

Checklist for Implementing Merchant-calculated Shipping

The following checklist will help you to ensure that you have correctly implemented merchant-calculated shipping.

  • Confirm that you have developed a web service that implements the Merchant Calculations API.

  • Ensure that your Checkout API request specifies the location of your calculations service as the value of the merchant-calculations-url parameter.

  • Ensure that your Checkout API request does not mix merchant-calculated shipping options with other types of shipping options.

  • Verify that you have specified a backup shipping cost using the price parameter. If you specify more than one merchant-calculated shipping option in your Checkout API request, you must specify a backup price for each of those options. If you do not specify a backup price for a shipping option and the merchant-calculation -callback fails for any reason, Google will not add shipping charges if the buyer selects that shipping option.

HTML Examples for Merchant-Calculated Shipping

The HTML examples below demonstrate several use cases for implementing merchant-calculated shipping. Please note that the examples only include the HTML input parameters relevant to shipping methods.

Example 1 – Using Merchant Calculated Shipping

The following example shows two merchant-calculated shipping methods. The first shipping method, which is for UPS Next Day Air shipping, has a default price of $20.00. This option also will not be offered if the shipping address is a P.O. box in the United States. The second option, which is for UPS Ground Shipping, has a default price of $15.00. The example also specifies that the merchant will calculate taxes as well as price adjustments associated with coupons or gift certificates.

<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.name"
  value="UPS Next Day Air"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.price"
  value="20.00"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.price.currency"
  value="USD"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.address-filters.allow-us-po-box"
  value="false"/>


<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-2.name"
  value="UPS Ground"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-2.price"
  value="15.00"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-2.price.currency"
  value="USD"/>

Example 2 – Using Address Filters and Shipping Restrictions

In this example, the merchant offers the same two shipping options as in example 1. However, in this example, the merchant has added shipping restrictions to specify that the next-day shipping option will not be available if the <merchant-calculation-callback> request fails and the shipping address is in either Alaska or Hawaii.

The following list explains how Google Checkout will handle different shipping addresses based on the HTML in the example:

  • If the customer enters any U.S. postal address that is not a P.O. box, Google Checkout will send a callback request instructing the merchant to calculate shipping costs for both shipping options.

    • If the callback request is successful, then Google will offer the two shipping options to the buyer using the shipping costs from the merchant's <merchant-calculation-response>.

    • If the callback request is not successful, and the shipping address is in the continental United States, Google will let the buyer choose either of the two shipping methods. In this case, the next-day shipping method will cost $20.00 and the ground shipping method will cost $15.00.

    • If the callback request is not successful, and the shipping address is in Alaska or Hawaii, Google will only offer the second shipping option at a cost of $15.00.

  • If the customer enters a U.S. postal address that is a P.O. box, Google Checkout will send a callback request instructing the merchant to calculate the shipping cost for the second shipping option, which is for ground shipping. Since the address filter for the first shipping option indicates that that option is not available for P.O. boxes, Google will not allow the customer to select that shipping option and will not ask the merchant to calculate the cost of that shipping option.

<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.name"
  value="UPS Next Day Air"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.price"
  value="20.00"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.price.currency"
  value="USD"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.address-filters.allow-us-po-box"
  value="false"/>

<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.shipping-restrictions.excluded-areas.us-state-area-1.state"
  value="AK"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-1.shipping-restrictions.excluded-areas.us-state-area-2.state"
  value="HI"/>

<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-2.name"
  value="UPS Ground"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-2.price"
  value="15.00"/>
<input type="hidden"
  name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-2.price.currency"
  value="USD"/>

HTML Parameter Definitions

allow-us-po-box

The allow-us-po-box parameter indicates whether a particular shipping method can be used to ship an order to a U.S. post office (P.O.) box. To prevent a flat-rate shipping option from being offered to customers who are shipping orders to P.O. boxes in the United States, include this parameter with a value of false in the shipping-restrictions for the shipping option. The default value for this parameter is true.

Associated recurring elements


The flat-rate-shipping or merchant-calculated-shipping element needs to be numbered to associate the shipping restriction (or address filter) with the appropriate shipping method.

API commands


Content format for parameter value


Boolean

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.shipping-restrictions.allow-us-po-box" value="false"/>
<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.[shipping-restrictions | address-filters].allow-us-po-box" value="false"/>

country-area
The country-area parameter identifies a region of the United States. Valid values for this parameter are:
CONTINENTAL_48 - All U.S. states except Alaska and Hawaii
FULL_50_STATES - All U.S. states
ALL - All U.S. postal service addresses, including military addresses, U.S. insular areas, etc.

Associated recurring elements


When the country-area parameter is associated with a shipping method, the us-country-area element and either the flat-rate-shipping or merchant-calculated-shipping element need to be numbered. When the country-area parameter is associated with a default tax table, the default-tax-rule and us-country-area elements must both be numbered. When the country-area parameter is associated with an alternate tax table, the alternate-tax-table, alternate-tax-rule and us-country-area elements must all be numbered.

API commands


Content format for parameter value


String

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.shipping-restrictions.[allowed-areas | excluded-areas].us-country-area-#.country-area" value="CONTINENTAL_48"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.[shipping-restrictions | address-filters].[allowed-areas | excluded-areas].us-country-area-#.country-area" value="CONTINENTAL_48"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.default-tax-rule-#.tax-areas.us-country-area-#.country-area" value="CONTINENTAL_48"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.alternate-tax-tables.alternate-tax-table-#.alternate-tax-rule-#.tax-areas.us-country-area-#.country-area" value="CONTINENTAL_48"/>


currency
The currency parameter identifies the unit of currency associated with a price, shipping cost or other monetary value. Every monetary value in a Google Checkout API request must specify the currency associated with that value. The value of the currency parameter must be a three-letter ISO 4217 currency code.

Associated recurring elements


The currency parameter includes recurring elements any time the monetary value associated with the currency also contains a recurring element. For example, in a Checkout API request, the unit-price parameter identifies the price of an item and contains the recurring item element. As such, the currency associated with the unit-price parameter value will also contain the repeating price parameter.

API commands


Content format for parameter value


String

Sample use(s)


In a Checkout API request:
item type="hidden" name="shopping-cart.items.item-1.unit-price" value="12.99"
item type="hidden" name="shopping-cart.items.item-1.unit-price.currency" value="USD"

In a new order notification:
order-adjustment.total-tax=1.38&order-adjustment.total-tax.currency=USD

In a refund order request:
amount=12.99&amount.currency=USD


merchant-calculations-url

The merchant-calculations-url parameter identifies the URL to which Google Checkout should send merchant-calculation-callback requests. Merchants only need to include this parameter in Checkout API requests if they have implemented the Merchant Calculations API.

Note: Your production calculation service must use port 443, which is the default port for HTTPS. You can use either port 443 or port 80 for your callback URL in the Sandbox environment.

API commands


Content format for parameter value


String (URI)

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.merchant-calculations.merchant-calculations-url" value="http://calculations.example.com"/>

name

In a Checkout API request, the name parameter value contains a string that can be used to identify a tax table or shipping method. The parameter value must be at least one non-space character and may not be longer than 255 characters. The name parameter can also be used in a Checkout API request to identify the name of a query string parameter that will be included in a web beacon URL for third-party conversion tracking. The parameter's value is the name that the third-party tracking provider uses in its web beacon URLs.

In a merchant calculation callback, the name parameter identifies the name of a shipping method.

In a new order notification, the name parameter specifies the name that Google uses to identify a promotion in the Merchant Center.

Associated recurring elements


When the name parameter specifies the name of a query string parameter that will be included in a web beacon URL for third-party conversion tracking, the parameterized-url element must be numbered to associate the URL with a particular web beacon. In addition, the url-parameter element must be numbered so that the parameter name may be associated with the parameter value, which is expressed using the type parameter. When the name parameter is associated with an alternate tax table, the alternate-tax-table element must be numbered. When the name parameter is associated with a shipping method in a Checkout API request, either the flat-rate-shipping, merchant-calculated-shipping or pickup element need to be numbered. When the name parameter is associated with a shipping method in a merchant calculation callback, the method element will be numbered. Finally, when the name parameter is associated with a promotion, the promotion element must be numbered so that the promotion name can be associated with a specific promotion.

Content format for parameter value


String

Sample use(s)


Identifying a shipping method in a Checkout API request:
input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.[flat-rate-shipping-# |merchant-calculated-shipping-# | pickup-shipping-#].name" value="Standard shipping"/

Identifying a tax table in a Checkout API request:
input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.alternate-tax-tables.alternate-tax-table-#.name" value="reduced"/

Identifying a URL parameter in a Checkout API request:
input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.parameterized-urls.parameterized-url-#.parameters.url-parameter-#.name" value="taxes"/

Identifying a shipping method in a merchant calculation callback:
calculate.shipping.method-#.name=FedEx

Identifying a promotion in a new order notification:
promotions.promotion-#.name=Google+10+off+50


postal-code-pattern

The postal-code-pattern parameter contains a postal code or a range of postal codes for a specific country. To specify a range of postal codes, use an asterisk as a wildcard operator. For example, you can provide a postal-code-pattern value of SW* to indicate that a shipping option is available or a tax rule applies in any postal code beginning with the characters SW.

Associated recurring elements


When the postal-code-pattern parameter is associated with a shipping method, the postal-area element and either the flat-rate-shipping or merchant-calculated-shipping element need to be numbered. When the postal-code-pattern parameter is associated with a default tax table, the default-tax-rule and postal-area elements must both be numbered. When the postal-code-pattern parameter is associated with an alternate tax table, the alternate-tax-table, alternate-tax-rule and postal-area elements must all be numbered.

API commands


Content format for parameter value


String

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.shipping-restrictions.[allowed-areas | excluded-areas].postal-area.postal-code-pattern" value="SW*"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.[shipping-restrictions | address-filters].[allowed-areas | excluded-areas].postal-area.postal-code-pattern" value="SW*"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.default-tax-rule-#.tax-areas.postal-area-#.postal-code-pattern" value="SW*"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.alternate-tax-tables.alternate-tax-table-#.alternate-tax-rule-#.tax-areas.postal-area-#.postal-code-pattern" value="SW*"/>


price

The price parameter contains the cost to ship an order using a particular shipping method.

Associated recurring elements


The parameter name must contain one of the flat-rate-shipping, pickup or merchant-calculated-shipping elements, and that element must be numbered to associate the price with a particular shipping method.

API commands


Content format for parameter value


Decimal

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.price" value="3.99"/>
<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.pickup-#.price" value="0.00"/>
<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.price" value="9.99"/>

state

The state parameter identifies a state where a particular tax rule is applied or where a particular shipping option is available or unavailable.

Associated recurring elements


When the state parameter is associated with a shipping method, the us-state-area element and either the flat-rate-shipping or merchant-calculated-shipping element need to be numbered. When the state parameter is associated with a default tax table, the default-tax-rule and us-state-area elements must both be numbered. When the state parameter is associated with an alternate tax table, the alternate-tax-table, alternate-tax-rule and us-state-area elements must all be numbered.

API commands


Content format for parameter value


String

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.shipping-restrictions.[allowed-areas | excluded-areas].us-state-area-#.state" value="CT"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.[shipping-restrictions | address-filters].[allowed-areas | excluded-areas].us-state-area-#.state" value="CT"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.default-tax-rule-#.tax-areas.us-state-area-#.state" value="CT"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.alternate-tax-tables.alternate-tax-table-#.alternate-tax-rule-#.tax-areas.us-state-area-#.state" value="CT"/>


world-area

The world-area parameter represents the entire world. This parameter indicates that a shipping option is available worldwide or that a particular tax rule applies worldwide.

For shipping options, the world-area parameter can only appear as a subtag of the allowed-areas parameter. (Including the world-area parameter as a subtag of the excluded-areas parameter would make the corresponding shipping option unavailable to all shipping addresses.) However, you can use the world-area parameter to indicate that a shipping option is available worldwide and then identify specific excluded areas where the shipping option is unavailable. Those excluded areas could identify regions that are covered by other shipping options or regions where you do not ship items.

For tax rules, Google Checkout will select the first tax rule that matches the customer's shipping address. As such, if you use the world-area parameter to define the area where a tax rule applies, that tax rule must appear last in the list of tax rules in your API request. See the XML Examples for Tax Areas to see a feed excerpt that uses the world-area parameter for tax rules.

Associated recurring elements


When the world-area parameter is associated with a shipping method, the world-area element and either the flat-rate-shipping or merchant-calculated-shipping element need to be numbered. When the world-area parameter is associated with a default tax table, the default-tax-rule and world-area elements must both be numbered. When the world-area parameter is associated with an alternate tax table, the alternate-tax-table, alternate-tax-rule and world-area elements must all be numbered.

API commands


Content format for parameter value


Complex

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.shipping-restrictions.[allowed-areas | excluded-areas].world-area-#" value=""/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.[shipping-restrictions | address-filters].[allowed-areas | excluded-areas].world-area-#" value=""/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.default-tax-rule-#.tax-areas.world-area-#" value=""/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.alternate-tax-tables.alternate-tax-table-#.alternate-tax-rule-#.tax-areas.world-area-#" value=""/>


zip-pattern

The zip-pattern parameter contains a zip code or a range of zip codes. To specify a range of zip codes, use an asterisk as a wildcard operator. For example, you can specify that a shipping option is available or a tax rule applies to zip codes 94040 through 94049 by entering 9404* as the zip-pattern value.

Associated recurring elements


When the zip-pattern parameter is associated with a shipping method, the us-zip-area element and either the flat-rate-shipping or merchant-calculated-shipping element need to be numbered. When the zip-pattern parameter is associated with a default tax table, the default-tax-rule and us-zip-area elements must both be numbered. When the zip-pattern parameter is associated with an alternate tax table, the alternate-tax-table, alternate-tax-rule and us-zip-area elements must all be numbered.

API commands


Content format for parameter value


String

Sample use(s)


<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-#.shipping-restrictions.[allowed-areas | excluded-areas].us-zip-area-#.zip-pattern" value="100*"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.merchant-calculated-shipping-#.[shipping-restrictions | address-filters].[allowed-areas | excluded-areas].us-zip-area-#.zip-pattern" value="100*"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.default-tax-rule-#.tax-areas.us-zip-area-#.zip-pattern" value="94043"/>

<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.alternate-tax-tables.alternate-tax-table-#.alternate-tax-rule-#.tax-areas.us-zip-area-#.zip-pattern" value="94043"/>