Use this guide to integrate the Google Pay payment handler for Google’s Universal Commerce Protocol (UCP) with Braintree as your payment provider. This enables AI-powered checkout experiences through Google AI Mode (Gemini), where Google Pay returns a tokenized credential that Braintree can process, and your server uses it to process the payment.Documentation Index
Fetch the complete documentation index at: https://docs.paypal.ai/llms.txt
Use this file to discover all available pages before exploring further.
How it works
In a standard Google Pay integration, tokenization happens client-side. With UCP, Google shifts this to the server side. The following table shows the key differences.| Integration detail | Standard integration | UCP or AI mode integration |
|---|---|---|
| Client SDK | Required in your web or mobile client | Not used in your client |
| Tokenization | Performed client-side through SDK | Google handles tokenization on server side |
| Single-use token delivery | SDK returns to client | Google includes it in checkout-complete payload |
| Parsing | SDK parses automatically | Merchant parses androidPayCards JSON |
- Discover your products through your product catalog.
- Create checkout sessions through the UCP specification.
- Send the tokenized Braintree payment, including the tokenized credential, to your server to complete checkout.
Prerequisites
- Active Braintree merchant account.
- Google Pay enabled in your Braintree Control Panel.
- UCP merchant registration with Google. Contact Google for enablement.
- Familiarity with Braintree’s
Transaction.saleorchargePaymentMethodGraphQL mutation.
Step 1: Configure Google Pay payment handler tokenization
When registering your UCP profile with Google, you will define a full Google Pay payment handler specification. The followingtokenizationSpecification block is the Braintree-specific section that belongs inside the allowed_payment_methods entry of that specification. For more information, see the Google Pay payment handler specification.
| Parameter | Description |
|---|---|
gateway | Set to braintree |
braintree:apiVersion | API version (v1) |
braintree:sdkVersion | Braintree client SDK version |
braintree:merchantId | Your Braintree public merchant ID |
braintree:clientKey | Your Braintree tokenization key |
braintree:clientKey requires a tokenization key. See the Braintree tokenization key documentation for details.Step 2: Handle the checkout payload
When Google calls your/checkout-session/{id}/complete endpoint, the payment payload includes the Braintree single-use token in the credential.token field.
Expected payload structure
credential.token contains a JSON string with the androidPayCards array. Parse it to extract the single-use token.
Step 3: Process the payment with Braintree
Use the extracted single-use token exactly as you would any other Braintree payment method. Using Braintree SDK (Node.js)Review Google Pay’s terms regarding vaulting network-tokenized cards and FPAN-based cards. Braintree treats the Google Pay-derived credential as a single-use payment method that may only be used once and expires after 3 hours if unused, so avoid flows that try to both charge and vault the same value.
Troubleshooting
Use the following information to diagnose and resolve common integration issues.Common errors
| Error | Cause | Solution |
|---|---|---|
Unknown or expired single-use payment method | Single-use token expired or wrong merchant ID |
|
Empty androidPayCards array | Tokenization failed | Verify tokenization key and merchant ID configuration. |
Verify your configuration
- Confirm the Braintree merchant ID is correct on your UCP Google Pay payment handler definition in the
tokenizationSpecificationsection. - Verify the tokenization key is valid and not expired.
- Ensure Google Pay is enabled in the Braintree Control Panel.