> For the complete documentation index, see [llms.txt](https://plexo.gitbook.io/rest-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plexo.gitbook.io/rest-api/wallets/google-pay/google-pay-web.md).

# Google Pay Web Integration

Use this flow when you want Plexo Hosted Checkout to render Google Pay inside the checkout experience.

In this model:

* You create a checkout session with Plexo
* You redirect the payer to the hosted checkout URL returned by Plexo
* Plexo renders the Google Pay button when the merchant has an active Google Pay integration
* You do not submit the Google Pay token to Plexo yourself

## When To Use This Flow

Choose Hosted Checkout when you want:

* Faster implementation with less client-side wallet logic
* Plexo to handle the hosted Google Pay experience
* A redirect checkout page instead of building your own wallet UI

## Prerequisites

1. Ask `soporte@plexo.com.uy` to enable Google Pay for the merchant with mode `hosted` or `both`
2. Create checkout sessions with `POST /v1/sessions`
3. Redirect the payer to the checkout session URL returned by Plexo

## Step 1: Create a Checkout Session

Hosted Google Pay availability is based on the merchant's active wallet configuration.

At session level:

* Merchant wallet configuration is the source of truth
* `settings.checkout.walletIntegrations.googlePay.enabled = false` opts out of Google Pay for that session
* `mode` is enriched by Plexo in the session response
* `dynamicShipping = true` enables Google Pay shipping callbacks for the hosted flow

If you send a `googlePay` object and want Google Pay available for that session, set `enabled` to `true`.

**Endpoint:** `POST /v1/sessions`

```bash
curl -X POST "https://api.plexo.com.uy/v1/sessions" \
  -u "username:password" \
  -H "Content-Type: application/json" \
  -d '{
    "merchantId": 12345,
    "referenceId": "order-123",
    "type": "checkout",
    "paymentRequest": {
      "referenceId": "payment-order-123",
      "invoiceNumber": "INV-123",
      "amount": {
        "total": 100.00,
        "currency": "UYU"
      }
    },
    "settings": {
      "checkout": {
        "walletIntegrations": {
          "googlePay": {
            "enabled": true,
            "dynamicShipping": true
          }
        }
      },
      "redirects": {
        "defaultUrl": "https://example.com/success",
        "cancelUrl": "https://example.com/cancel"
      }
    }
  }'
```

### Example Response

```json
{
  "id": "ses_abc123",
  "referenceId": "order-123",
  "type": "checkout",
  "status": "pending",
  "actions": [
    {
      "rel": "self",
      "method": "REDIRECT",
      "href": "https://checkout.plexo.com.uy/1c4f6f2f9d834f69a1b2c3d4e5f6a7b8?t=..."
    }
  ],
  "settings": {
    "checkout": {
      "walletIntegrations": {
        "googlePay": {
          "enabled": true,
          "mode": "both",
          "dynamicShipping": true
        }
      }
    }
  }
}
```

## Step 2: Open Plexo Hosted Checkout

Use the `REDIRECT` action returned by the session to open the hosted checkout as a full-page flow.

Google Pay appears in hosted checkout only when:

* The merchant has an active Google Pay integration
* The session has not opted out of Google Pay
* The hosted page is opened through the active session URL returned by Plexo

## Optional: Dynamic Shipping

If you set `settings.checkout.walletIntegrations.googlePay.dynamicShipping = true`, the hosted flow can refresh the active session when the payer changes shipping details during the Google Pay flow.

Plexo handles the hosted Google Pay shipping callback internally inside the authenticated hosted web-session context. You do not call a separate public endpoint for this flow.

## CSP

If your frontend sets a restrictive Content Security Policy, allow navigation to the checkout host returned by Plexo.

**Example CSP Header:**

```http
Content-Security-Policy: default-src 'self'; form-action 'self' https://checkout.plexo.com.uy; navigate-to 'self' https://checkout.plexo.com.uy;
```

## Next Steps

* [Google Pay Integration Guide](/rest-api/wallets/google-pay.md)
* [Google Pay API Integration](/rest-api/wallets/google-pay/google-pay-api.md)
* [Wallet Integrations API Reference](/rest-api/api-reference/wallet-integrations.md)
* [Payment Processing Guide](/rest-api/payments/payment-processing.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://plexo.gitbook.io/rest-api/wallets/google-pay/google-pay-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
