# Google Pay™

You can accept payments through Google Pay™ via [Checkout](/online-payments/checkout/accepting-payments/google-pay-tm.md) (Hosted Payments Page - HPP) or via [eComm](/api-reference/open-api-references/ecommerce.md) API.

## Hosted checkout integration

Follow the guide [here](/online-payments/checkout/accepting-payments/google-pay-tm.md) for integrating Hosted Checkout with Google Pay as a payment option.

## Server-to-Server integration

This guide covers a two-part integration: (1) a client-side Google Pay button that collects an encrypted payment token, and (2) a server-side call to Verifone [eCommerce API](/api-reference/open-api-references/ecommerce/ecom-payments.md#post-api-v2-transactions-wallet) to process it.

Follow the integration steps below to process transactions via Verifone eComm API.

## Required fields <a href="#required-fields" id="required-fields"></a>

<table><thead><tr><th width="244" valign="top">Parameters</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><code>payment_provider_contract</code></td><td>Find it in <em>Verifone Central -> Administration -> Payment Provider Contracts</em>. Copy the Payment Provider Contract ID.</td></tr><tr><td valign="top"><code>amount</code></td><td>Amount of the transaction</td></tr><tr><td valign="top"><code>merchant_reference</code></td><td>Unique UUID you generate and can link the transaction to when the customer returns</td></tr><tr><td valign="top"><code>currency_code</code></td><td>More on the all currencies supported here: Verifone <a href="/spaces/OiXbo96Og9EN7rz2U44K/pages/OnU159hHWJkJp14gc6AP">eCommerce</a> API</td></tr><tr><td valign="top"><code>wallet_type</code></td><td>string Enum: "GOOGLE_PAY"</td></tr><tr><td valign="top"><code>wallet_payload</code></td><td><p>object</p><p>The encrypted payload object provided by the Wallet on the frontend</p></td></tr></tbody></table>

A Google Pay web integration consists of implementing both client-side and server-side components. You will need to implement the following:

* Configure the Verifone payment gateway ID and your merchant ID to initialize the Google pay client.
  * <https://developers.google.com/pay/api/web/guides/tutorial>
* Use the Google Pay token to make a wallet transaction API call and complete the session based on the response&#x20;
  * Verifone [eCommerce](/api-reference/open-api-references/ecommerce.md) API

### Code sample <a href="#code-sample" id="code-sample"></a>

```json
// Specify verifone as the gateway and define your wallet contract
const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'verifone',
    'gatewayMerchantId': 'BCR2DN6T2OAK7HIW'
  }
};

// Specify your google pay merchant ID and name when setting up your paymentDataRequest
  paymentDataRequest.merchantInfo = {
    // @todo a merchant ID is available for a production environment after approval by Google
    // See {@link https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist|Integration checklist}
    merchantId: 'YOUR_MERCHANT_ID',
    merchantName: 'YOUR_MERCHANT_NAME'
  };

// Pass the google pay token to your server to make the wallet transaction API call
function onGooglePaymentButtonClicked() {
  const paymentDataRequest = getGooglePaymentDataRequest();
  paymentDataRequest.transactionInfo = getGoogleTransactionInfo();

  const paymentsClient = getGooglePaymentsClient();
  paymentsClient.loadPaymentData(paymentDataRequest)
      .then(function(paymentData) {
        // handle the response
  paymentToken = paymentData.paymentMethodData.tokenizationData.token;
      fetch("YOUR_SERVER", {
      method: "POST",
        headers: {"Content-Type": "application/json"},
        body: getPayload(JSON.parse(paymentToken)),
      }).then((res) => res.json())
        .then((res) => {
// handle wallet transaction response
          if (res.status.includes('AUTHORIZED')) {
          alert('Payment Successful');
          }
      })
         .catch((err) => console.log(err));
      })
      .catch(function(err) {
        // show error in developer console for debugging
        console.error(err);
      });
}
```

&#x20;


---

# Agent Instructions: 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:

```
GET https://docs.verifone.com/online-payments/api-integration/google-pay-tm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
