- Order breakdown: show subtotal, shipping, taxes, and discounts instead of a single total.
- Shipping address updates: recalculate the order when the customer picks or changes their shipping address, without leaving the sheet.
- Shipping method selector: let the customer choose Standard, Express, or Same-day on the sheet, with instant price updates.
Requirements
How it works
- Your backend adds
summary_itemsand/orshipping_methodswhen it creates the checkout session. - Your app registers
onShippingAddressChangedwhen it starts the payment flow. - On the Google Pay sheet, switching shipping method updates the price instantly without calling your app. Picking or changing the shipping address calls your handler, so you can return new totals, new methods, or an error.
- After the customer authorizes, the one-time token includes a
shippingobject with the selected method and the full address.
- Every
summary_itemslist must end with the grand total. Itsamountis the total shown on the sheet, and itslabelis shown next to it (we recommend your store name). - All amounts must use the session currency. A different currency makes the SDK ignore that breakdown or response.
Step 1: Show an order breakdown (backend only)
Addsummary_items when you create the checkout session:
- The ids
subtotal,shipping,tax, anddiscountuse Google’s native line types. Any other id shows as a regular line. The customer only sees your labels. - The last entry must be the grand total and must match the session amount (tolerance 0.001). If it doesn’t, the sheet shows only the total.
- Discounts can be negative, for example
-5.00. - If the list is invalid (missing label or amount, mixed currencies, no total), the sheet shows only the total.
- When you also send
shipping_methods(Step 2), each method uses its own breakdown and this list is ignored.
Step 2: Offer shipping methods on the sheet
Addshipping_methods to the checkout session. Each method has its own summary_items, so the sheet can update the price as soon as the customer switches method:
- Every method needs a unique id. If two methods share an id, the selector is not shown.
- The first method is preselected.
- The price is shown in the option name, for example “$5.00: Standard shipping”.
detailis shown as the description. - Switching methods never calls your app or your backend. The total comes from that method’s
summary_items. - Send at least one line plus the total in each method’s
summary_items. A method with only the total shows no breakdown and Google’s default total label. - If any method is invalid, the selector is not shown.
delivery_estimate({ "from": "YYYY-MM-DD", "to": "YYYY-MM-DD" }) is accepted, but Google Pay on Android does not display it.
Step 3: React to shipping address changes
RegisteronShippingAddressChanged when you start the flow:
startPayment, startPaymentLite, startPaymentSeamlessLite, and continuePayment. Register it every time you start a flow.
What you receive: ShippingInfo
Before authorization, Google shares only part of the address, which is enough to quote shipping and taxes:
Every field can be null. The full address arrives in the one-time token (Step 4).
What you return: ShippingUpdate
Callcomplete(...) with any combination of these, or with null to keep the sheet as it is:
Rules
Step 4: Read the result in the one-time token
After the customer authorizes, the one-time token you receive incallbackOTT includes a shipping object with the full address and the selected method:
methodis the one selected on the sheet, or the first one if the customer didn’t change it.summary_itemsare not sent back.- If you don’t register a handler, the token doesn’t include
shipping.
What happens in each case
Good to know
- The addresses belong to the customer’s Google account. In Google Pay’s TEST environment you’ll only see Google’s test addresses; you can’t add your own.
- The selected method stays selected when the customer changes the address, unless you return new methods.
- Privacy: the SDK never logs addresses, emails, or payment data.
- Google Pay Pix (Brazil) is not affected.
Testing checklist
- Upgrade to SDK 2.24.0, set
minSdkVersion23, and build. - Create a session with
summary_itemsonly. The sheet shows the breakdown and the right total. - Create a session with
shipping_methodsand register the handler. The sheet shows the selector with the first method selected. - Switch methods. The price updates and your handler is not called.
- Change the address. Your handler receives it; return new totals and check the sheet updates.
- Return an error for an address you don’t serve. The sheet shows your message. Check that your server also rejects that address, because the customer can still pay.
- Authorize. The token includes
shippingwith the method and the full address. - Remove the handler and the session fields. Everything works as before.