Web
1. Load the Google Pay SDK
2. Read the configuration from the cart
Firmly returns a ready-to-use configuration on the cart. Find the entry inpayment_method_options whose type is "GooglePay"; its config is a Google PaymentDataRequest. If there is no such entry, the merchant does not accept Google Pay. An entry can also be present without config: the merchant has Google Pay enabled but its tokenization settings are incomplete, so there is no request to hand to the SDK. Treat both cases the same way and do not show the button.
3. Check availability and render the button
4. Mint the token
The token and card network only exist inside the click handler, so the handler passes them on tocompleteOrder (step 6) instead of leaving them for later code to pick up.
5. Prepare the cart
Google Pay completes an already-prepared cart. For a physical-goods order the cart must carry a shipping address and a selected shipping method before completion. If the Google Pay sheet collected the address, persist it withcart/shipping-info and select a method with cart/shipping-method first, inside the click handler and before calling completeOrder.
6. Complete the order
Merchants whose
config names Braintree as the gateway (allowedPaymentMethods[0].tokenizationSpecification.parameters.gateway is "braintree") complete the order with a Braintree payment nonce instead of the Google Pay token. See Braintree merchants (nonce flow).Environment
The sheet environment (TEST or PRODUCTION) comes from the cart response, at shop_properties.google_pay.environment. Read it from there rather than hardcoding it — a test merchant must render the test sheet and a live merchant the live sheet.
Android
The steps map one to one onto the web flow:- Use Google’s Android Google Pay API on the client (
PaymentsClient,isReadyToPay,loadPaymentData). - Read the same
payment_method_options[].configfrom the Firmly cart and pass it to the AndroidPaymentsClient— it is the samePaymentDataRequest. - On a successful payment, read the token from the Android
PaymentDataresult. - Prepare the cart (
cart/shipping-info,cart/shipping-method) exactly as on web. - POST the token to the same endpoint:
Related
- Complete Google Pay Order — the endpoint reference
- Express Checkout