> ## Documentation Index
> Fetch the complete documentation index at: https://firmly.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Complete Google Pay Order

> Places the order using the token minted by the Google Pay sheet

## Overview

Completes the checkout in a single call. The wallet ceremony happens client-side: the client reads the ready-to-use Google Pay configuration from the cart, calls `googlePay.loadPaymentData()` to mint a token, and posts that token here. Google Pay has no separate start or authorize step; this endpoint authorizes and places the order. The cart must already carry a shipping address and a selected shipping method (see [Preparing the cart](#preparing-the-cart)). Merchants that process Google Pay through Braintree take a payment nonce instead of the token; see [Braintree merchants (nonce flow)](#braintree-merchants-nonce-flow).

> [!NOTE]
>
> Google Pay is enabled per merchant. Look for the entry with `"type": "GooglePay"` in the cart's `payment_method_options`; its `config` is the `PaymentDataRequest` to pass to the Google Pay SDK (see [Discovering Google Pay support](#discovering-google-pay-support)). No entry, or an entry without `config`, means the sheet cannot be built for this merchant: do not show the button. For the client-side steps, see [Integrate Google Pay](https://firmly.mintlify.site/api-reference/payment/express-checkout/google-pay-integration.md).

## Authentication

**x-firmly-authorization** `string` *required*

Device authentication token from Browser Session

## Path Parameters

**domain** `string` *required*

The merchant domain (e.g., "merchant.example.com")

## Request Body

**attributes** `object` *required*

Google Pay payment attributes

**Attributes**

**google\_pay\_token** `string`

Required for every merchant except Braintree ones. The token from `googlePay.loadPaymentData()`: `paymentData.paymentMethodData.tokenizationData.token`. For a DIRECT merchant this is the raw ECv2 token, which Firmly's vault decrypts with the merchant's private key. For a PSP-gateway merchant it is the gateway token (for example a Stripe `pm_`/`tok_` id or an Adyen token blob). Braintree merchants send `nonce` instead; a `google_pay_token` sent to a Braintree merchant is not unwrapped server-side and fails with `ErrorBadRequest`.

**nonce** `string`

Braintree merchants only, in place of `google_pay_token`. The payment method nonce returned by Braintree's Google Pay SDK (`googlePayment.parseResponse(paymentData)`). See [Braintree merchants (nonce flow)](#braintree-merchants-nonce-flow).

**device\_data** `object`

Braintree merchants only, optional. Device data from Braintree's data collector, forwarded to the merchant for fraud screening when the merchant uses it.

**google\_pay\_card\_network** `string`

The card network the shopper selected, from `paymentData.paymentMethodData.info.cardNetwork` (e.g. `VISA`). Surfaced as `payment_summary.card_type`.

**google\_pay\_card\_details** `string`

Last four digits reported by the sheet, from `paymentData.paymentMethodData.info.cardDetails`. Surfaced as `payment_summary.last_four`.

**google\_pay\_description** `string`

The display string the wallet composed (e.g. `Visa •••• 1234`), from `paymentData.paymentMethodData.description`. Surfaced as `payment_summary.description`; preferred for the confirmation screen.

**google\_pay\_address** `object`

The address the Google Pay sheet returned. Used as the shipping address when the merchant checkout has no separate shipping form. For a DIRECT merchant it is also the billing address sent to the vault (the ECv2 token carries none); when omitted, billing falls back to the cart's shipping address. There is no separate billing-address parameter. Required for Braintree merchants, together with `email`.

**Google Pay Address**

**name** `string`

Recipient name

**address1** `string`

Street address line 1

**address2** `string`

Street address line 2

**address3** `string`

Street address line 3 (appended to line 2)

**locality** `string`

City

**administrativeArea** `string`

State or province

**iso3166AdministrativeArea** `string`

ISO 3166-2 subdivision code (e.g., `US-WA`); takes precedence over `administrativeArea`

**postalCode** `string`

Postal code

**countryCode** `string`

ISO country code

**phoneNumber** `string`

Contact phone number

**email** `string`

Buyer email, when the Google Pay sheet collected it. Required for Braintree merchants, together with `google_pay_address`.

## Response

Returns the order confirmation object.

**cart\_id** `string`

Unique identifier for the cart

**platform\_order\_number** `string`

The order number from the merchant platform

**cart\_status** `string`

Status of the cart (e.g., "submitted")

**urls** `object`

Relevant URLs for the order

**URLs**

**thank\_you\_page** `string`

URL to the merchant's order confirmation page

**line\_items** `array`

Array of items in the order

**shipping\_info** `object`

Delivery address details (taken from `google_pay_address` when provided)

**billing\_info** `object`

Billing address details

**payment\_summary** `object`

Summary of the Google Pay payment, for the confirmation screen

**Payment Summary**

**payment\_type** `string`

`"GooglePay"` for this gateway

**card\_type** `string`

Card network in display form (e.g. `"Visa"`), from `google_pay_card_network`

**last\_four** `string`

Last four digits, from `google_pay_card_details`

**description** `string`

The wallet's display string, from `google_pay_description`

**total** `object`

Grand total including all costs

## Code Example

```javascript JavaScript theme={null}
// Mint the token from the cart's ready-to-use PaymentDataRequest, then place the order
const entry = cart.payment_method_options.find((o) => o.type === 'GooglePay');
const paymentData = await googlePay.loadPaymentData(entry.config);
const { tokenizationData, info, description } = paymentData.paymentMethodData;

const response = await fetch(
  'https://api.firmly.work/api/v1/domains/merchant.example.com/express/google-pay/complete-order',
  {
    method: 'POST',
    headers: {
      'x-firmly-authorization': authToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      attributes: {
        google_pay_token: tokenizationData.token,
        google_pay_card_network: info?.cardNetwork,
        google_pay_card_details: info?.cardDetails,
        google_pay_description: description
      }
    })
  }
);

const order = await response.json();
if (!response.ok) throw new Error(order.description || 'Google Pay order failed');
if (order.urls?.thank_you_page) {
  window.location.href = order.urls.thank_you_page;
}
```

```python Python theme={null}
import requests

response = requests.post(
    'https://api.firmly.work/api/v1/domains/merchant.example.com/express/google-pay/complete-order',
    headers={
        'x-firmly-authorization': auth_token,
        'Content-Type': 'application/json'
    },
    json={
        'attributes': {
            'google_pay_token': google_pay_token,
            'google_pay_card_network': 'VISA',
            'google_pay_card_details': '1234',
            'google_pay_description': 'Visa •••• 1234'
        }
    }
)

order = response.json()
print(f"Order placed: {order['platform_order_number']}")
```

```bash cURL theme={null}
curl -X POST https://api.firmly.work/api/v1/domains/merchant.example.com/express/google-pay/complete-order \
  -H "x-firmly-authorization: YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"attributes": {"google_pay_token": "ECv2_TOKEN_FROM_WALLET", "google_pay_card_network": "VISA", "google_pay_card_details": "1234"}}'
```

## Response Example

```json theme={null}
{
  "cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
  "platform_order_number": "6800018416",
  "cart_status": "submitted",
  "urls": {
    "thank_you_page": "https://merchant.example.com/checkout/onepage/success/"
  },
  "line_items": [
    {
      "line_item_id": "3e66bef5-43f5-4a80-8957-91c5c8233163",
      "sku": "MT12",
      "quantity": 1,
      "description": "Cassius Sparring Tank",
      "price": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" }
    }
  ],
  "shipping_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "WA",
    "country": "US",
    "postal_code": "98101"
  },
  "billing_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "WA",
    "country": "US",
    "postal_code": "98101"
  },
  "payment_summary": {
    "payment_type": "GooglePay",
    "card_type": "Visa",
    "last_four": "1234",
    "description": "Visa •••• 1234"
  },
  "total": { "currency": "USD", "value": 30, "number": 3000, "symbol": "$" }
}
```

## Discovering Google Pay support

A client learns that a merchant accepts Google Pay, and gets the configuration to build the sheet, from the cart response. In `payment_method_options`, find the entry whose `type` is `"GooglePay"` (`wallet: "google_pay"`). Its `config` is a Google Pay [`PaymentDataRequest`](https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest): pass it straight to `googlePay.loadPaymentData()`. No entry means the merchant does not accept Google Pay. An entry without `config` means the merchant has Google Pay enabled but its tokenization settings are incomplete, so no request can be built: do not show the button in that case either.

```json theme={null}
{
  "payment_method_options": [
    { "type": "CreditCard", "wallet": "user" },
    {
      "type": "GooglePay",
      "wallet": "google_pay",
      "config": {
        "apiVersion": 2,
        "apiVersionMinor": 0,
        "merchantInfo": { "merchantName": "Example Store", "merchantId": "BCR2DN0000000000" },
        "allowedPaymentMethods": [
          {
            "type": "CARD",
            "parameters": {
              "allowedAuthMethods": ["PAN_ONLY"],
              "allowedCardNetworks": ["VISA", "MASTERCARD", "AMEX", "DISCOVER"],
              "billingAddressRequired": true,
              "billingAddressParameters": { "format": "FULL" }
            },
            "tokenizationSpecification": {
              "type": "DIRECT",
              "parameters": { "protocolVersion": "ECv2", "publicKey": "BASE64_ENCODED_PUBLIC_KEY" }
            }
          }
        ],
        "transactionInfo": { "currencyCode": "USD", "totalPriceStatus": "ESTIMATED", "totalPrice": "32.00" }
      }
    }
  ]
}
```

`emailRequired` and `shippingAddressRequired` are set on the config only when the cart needs shipping and does not yet hold a shipping address, so the sheet does not collect an address the cart already has.

The `PaymentDataRequest` carries no environment. The sheet environment (`TEST` or `PRODUCTION`) is exposed at `shop_properties.google_pay.environment` on the cart response; read it from there rather than hardcoding it on the client.

## Preparing the cart

This endpoint completes an already-prepared cart: Google Pay mints a payment token, it does not build the cart. For a physical-goods order, the cart must carry a shipping address and a selected shipping method before you complete.

* If the cart already has shipping (the shopper entered it on the page), complete directly with the token.
* For a guest flow where the Google Pay sheet collects the address, persist it with [Set Shipping Info](https://firmly.mintlify.site/api-reference/simple-cart-api/checkout/set-shipping-info.md), select a method with [Set Shipping Method](https://firmly.mintlify.site/api-reference/simple-cart-api/checkout/set-shipping-method.md), then complete.

The config's `transactionInfo.totalPriceStatus` is `ESTIMATED` until a shipping method is selected, because shipping and tax are not yet known, and `FINAL` afterwards. If the shopper authorizes on an estimated total and shipping or tax then raise it, confirm the final total with the shopper before completing: this API flow does not push an updated total back into the Google Pay sheet.

## Braintree merchants (nonce flow)

A merchant that processes Google Pay through Braintree is recognisable from its `config`: `allowedPaymentMethods[0].tokenizationSpecification` has `type: "PAYMENT_GATEWAY"` and `parameters.gateway: "braintree"`, with the Braintree key under `parameters` (`braintree:tokenizationKey` or `braintree:clientKey`). For these merchants Firmly does not unwrap the Google Pay token; the merchant's checkout takes a Braintree payment method nonce, so the client mints the nonce with Braintree's Google Pay SDK and sends it here as `nonce`.

1. Load Braintree's `client` and `google-payment` modules and create a client with the key from `parameters`.
2. Create the Google Payment instance (`braintree.googlePayment.create({ client, googlePayVersion: 2, googleMerchantId })`) and build the request with `googlePayment.createPaymentDataRequest({ transactionInfo, emailRequired: true, shippingAddressRequired: true })`, taking `transactionInfo` from the cart's `config`. Braintree merchants require the address and the email on this call, so request both even when the cart's `config` does not.
3. Call `loadPaymentData()`, then `googlePayment.parseResponse(paymentData)` to obtain the nonce.
4. Post `nonce`, the sheet's `shippingAddress` as `google_pay_address` and the sheet's `email`. `google_pay_token` is not sent.

```json theme={null}
{
  "attributes": {
    "nonce": "fake-android-pay-nonce",
    "google_pay_address": {
      "name": "John Smith",
      "address1": "123 Main St",
      "locality": "Seattle",
      "administrativeArea": "WA",
      "postalCode": "98101",
      "countryCode": "US",
      "phoneNumber": "2065551212"
    },
    "email": "john@example.com"
  }
}
```

The response is the same order confirmation object. A missing `nonce` fails with `ErrorBadRequest` ("Missing Google Pay nonce"); a missing `google_pay_address` or `email` fails with `ErrorBadRequest` from the merchant adapter. `google_pay_card_network`, `google_pay_card_details` and `google_pay_description` are not used on this flow.

## Error Responses

| Code | Description |
| - | - |
| `ErrorCartNotFound` | No active cart for this domain |
| `ErrorBadRequest` | Token flow: missing `google_pay_token` on a PSP-gateway merchant. Braintree flow: missing `nonce`, `google_pay_address` or `email`, or `google_pay_token` sent instead of `nonce` |
| `ErrorPaymentMethodNotAvailable` | DIRECT merchant: `google_pay_token` is missing, or no billing address is available from `google_pay_address` or the cart; or Google Pay is not available for this cart |
| `ErrorGatewayNotFound` | Google Pay is not enabled for this merchant |
| `ErrorMissingShippingMethod` | No shipping method selected |
| `ErrorMissingTaxSync` | Tax has not been calculated |
| `ErrorCheckout` | Checkout failed at the merchant |
| `ErrorCaptchaRequired` | The merchant requires a captcha challenge before placing the order |
| `ErrorRateLimited` | Too many requests |

## Related Endpoints

* [Integrate Google Pay](https://firmly.mintlify.site/api-reference/payment/express-checkout/google-pay-integration.md) - Client-side steps with Google's SDK
* [Express Checkout overview](https://firmly.mintlify.site/api-reference/payment/express-checkout/overview.md) - All express gateways
* [Complete Order (Credit Card)](https://firmly.mintlify.site/api-reference/payment/complete-order-v1.md) - Alternative credit card flow
* [Complete Apple Pay Order](https://firmly.mintlify.site/api-reference/payment/express-checkout/complete-order-apple-pay.md) - Apple Pay express flow


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.