---
title: "Google Pay for API only"
description: "Add Google Pay to an existing API-only integration."
url: "https://docs.adyen.com/payment-methods/google-pay/api-only"
source_url: "https://docs.adyen.com/payment-methods/google-pay/api-only.md"
canonical: "https://docs.adyen.com/payment-methods/google-pay/api-only"
last_modified: "2023-05-31T18:51:00+02:00"
language: "en"
---

# Google Pay for API only

Add Google Pay to an existing API-only integration.

[View source](/payment-methods/google-pay/api-only.md)

Accept Google Pay payments using our APIs, and build your own payment form to have full control over the look and feel of your checkout page.

## Requirements

Before starting your Google Pay integration:

1. [Add in your Customer Area](/payment-methods/add-payment-methods).

2. Make sure that you have integrated [Checkout API v67 or later](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only\&version=71#get-available-payment-methods).

3. Integrate Google Pay API with Adyen as your gateway. Follow the procedure in the Google Pay documentation to integrate your [web](https://developers.google.com/pay/api/web/guides/setup) or [Android](https://developers.google.com/pay/api/android/guides/setup) application.

   In the step where you choose a payment tokenization method, choose **Gateway**. Set **adyen** as your `gateway` and provide your merchant or company account name in the `gatewayMerchantId` parameter.

   **Defining payment gateway for Web**

   ```js
   "tokenizationSpecification": {
     "type": "PAYMENT_GATEWAY",
     "parameters": {
       "gateway": "adyen",
       "gatewayMerchantId": "YOUR_MERCHANT_ACCOUNT_NAME"
     }
   }
   ```

## Build your payment form for Google Pay

Show Google Pay as an available payment method in countries or regions where Google Pay is supported. When the shopper selects Google Pay, they are presented with the payment sheet.

We provide logos for Google Pay which you can use on your payment form. For more information, refer to [Downloading logos](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#downloading-logos).

You can also submit a [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) request specifying:

* [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods): Country or region where Google Pay is supported. For example, **NL**.
* [amount.currency](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-amount): Any supported currency. For example, **EUR**.
* [channel](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-channel): Set this to **Web** if the payment is being initiated on the web, or **Android** for in-app payments.

In the response, you receive `paymentMethod.type`: **googlepay**.

## Make a payment

1. Get the `token` from the [`PaymentData` ](https://developers.google.com/pay/api/web/reference/response-objects#PaymentData)response from the Google Pay API.

2. From your server, make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request providing:

   * `paymentMethod.type`: **googlepay**
   * `googlePayToken`: The `token` you received from the Google Pay API [`PaymentData` ](https://developers.google.com/pay/api/web/reference/response-objects#PaymentData)response.\
     For more information about the fields this token contains, refer to [Google Pay API documentation](https://developers.google.com/pay/api/web/guides/resources/payment-data-cryptography#payment-method-token-structure).
   * `browserInfo`: Required if you want to trigger [3D Secure authentication](/online-payments/3d-secure/redirect-3ds2).
   * `returnUrl`: URL where the shopper will be redirected after completing a 3D Secure authentication.

   #### curl

   ```bash
   curl https://checkout-test.adyen.com/v68/payments \
   -H 'x-api-key: ADYEN_API_KEY' \
   -H 'content-type: application/json' \
   -d '{
     "merchantAccount":"ADYEN_MERCHANT_ACCOUNT",
     "reference":"YOUR_ORDER_NUMBER",
     "amount":{
       "currency":"EUR",
       "value":1000
     },
     "paymentMethod":{
       "type":"googlepay",
       "{hint:Token from Google Pay API}googlePayToken{/hint}": "STATE_DATA"
     },
      "{hint:Required for 3D Secure}browserInfo{/hint}":{
         "userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
         "acceptHeader":"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
         "language":"nl-NL",
         "colorDepth":24,
         "screenHeight":723,
         "screenWidth":1536,
         "timeZoneOffset":0,
         "javaEnabled":true
      },
     "returnUrl":"https://your-company.example.com/checkout?shopperOrder=12xy.."
   }'
   ```

   #### Java

   ```java
   // Adyen Java API Library v27.0.0
   import com.adyen.Client;
   import com.adyen.enums.Environment;
   import com.adyen.model.checkout.*;
   import java.time.OffsetDateTime;
   import java.util.*;
   import com.adyen.model.RequestOptions;
   import com.adyen.service.checkout.*;

   // For the live environment, additionally include your liveEndpointUrlPrefix.
   Client client = new Client("ADYEN_API_KEY", Environment.TEST);

   // Create the request object(s)
   Amount amount = new Amount()
     .currency("EUR")
     .value(1000L);

   GooglePayDetails googlePayDetails = new GooglePayDetails()
     .googlePayToken("STATE_DATA")
     .type(GooglePayDetails.TypeEnum.GOOGLEPAY);

   BrowserInfo browserInfo = new BrowserInfo()
     .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
     .screenWidth(1536)
     .javaEnabled(true)
     .screenHeight(723)
     .timeZoneOffset(0)
     .userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36")
     .language("nl-NL")
     .colorDepth(24);

   PaymentRequest paymentRequest = new PaymentRequest()
     .reference("YOUR_ORDER_NUMBER")
     .amount(amount)
     .merchantAccount("ADYEN_MERCHANT_ACCOUNT")
     .paymentMethod(new CheckoutPaymentMethod(googlePayDetails))
     .returnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..")
     .browserInfo(browserInfo);

   // Send the request
   PaymentsApi service = new PaymentsApi(client);
   PaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey("UUID"));
   ```

   #### PHP

   ```php
   // Adyen PHP API Library v19.0.0
   use Adyen\Client;
   use Adyen\Environment;
   use Adyen\Model\Checkout\Amount;
   use Adyen\Model\Checkout\CheckoutPaymentMethod;
   use Adyen\Model\Checkout\BrowserInfo;
   use Adyen\Model\Checkout\PaymentRequest;
   use Adyen\Service\Checkout\PaymentsApi;

   $client = new Client();
   $client->setXApiKey("ADYEN_API_KEY");
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   $client->setEnvironment(Environment::TEST);


   // Create the request object(s)
   $amount = new Amount();
   $amount
     ->setCurrency("EUR")
     ->setValue(1000);

   $checkoutPaymentMethod = new CheckoutPaymentMethod();
   $checkoutPaymentMethod
     ->setGooglePayToken("STATE_DATA")
     ->setType("googlepay");

   $browserInfo = new BrowserInfo();
   $browserInfo
     ->setAcceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
     ->setScreenWidth(1536)
     ->setJavaEnabled(true)
     ->setScreenHeight(723)
     ->setTimeZoneOffset(0)
     ->setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36")
     ->setLanguage("nl-NL")
     ->setColorDepth(24);

   $paymentRequest = new PaymentRequest();
   $paymentRequest
     ->setReference("YOUR_ORDER_NUMBER")
     ->setAmount($amount)
     ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT")
     ->setPaymentMethod($checkoutPaymentMethod)
     ->setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..")
     ->setBrowserInfo($browserInfo);

   $requestOptions['idempotencyKey'] = 'UUID';

   // Send the request
   $service = new PaymentsApi($client);
   $response = $service->payments($paymentRequest, $requestOptions);
   ```

   #### C\#

   ```cs
   // Adyen .net API Library v17.0.0
   using Adyen;
   using Environment = Adyen.Model.Environment;
   using Adyen.Model;
   using Adyen.Model.Checkout;
   using Adyen.Service.Checkout;

   // For the live environment, additionally include your liveEndpointUrlPrefix.
   var config = new Config()
   {
       XApiKey = "ADYEN_API_KEY",
       Environment = Environment.Test
   };
   var client = new Client(config);

   // Create the request object(s)
   Amount amount = new Amount
   {
     Currency = "EUR",
     Value = 1000
   };

   GooglePayDetails googlePayDetails = new GooglePayDetails
   {
     GooglePayToken = "STATE_DATA",
     Type = GooglePayDetails.TypeEnum.Googlepay
   };

   BrowserInfo browserInfo = new BrowserInfo
   {
     AcceptHeader = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
     ScreenWidth = 1536,
     JavaEnabled = true,
     ScreenHeight = 723,
     TimeZoneOffset = 0,
     UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
     Language = "nl-NL",
     ColorDepth = 24
   };

   PaymentRequest paymentRequest = new PaymentRequest
   {
     Reference = "YOUR_ORDER_NUMBER",
     Amount = amount,
     MerchantAccount = "ADYEN_MERCHANT_ACCOUNT",
     PaymentMethod = new CheckoutPaymentMethod(googlePayDetails),
     ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy..",
     BrowserInfo = browserInfo
   };

   // Send the request
   var service = new PaymentsService(client);
   var response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"});
   ```

   #### NodeJS (JavaScript)

   ```js
   // Adyen Node API Library v18.0.0
   // Require the parts of the module you want to use
   const { Client, CheckoutAPI } = require('@adyen/api-library');
   // Initialize the client object
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

   // Create the request object(s)
   const paymentRequest = {
     merchantAccount: "ADYEN_MERCHANT_ACCOUNT",
     reference: "YOUR_ORDER_NUMBER",
     amount: {
       currency: "EUR",
       value: 1000
     },
     paymentMethod: {
       type: "googlepay",
       googlePayToken: "STATE_DATA"
     },
     browserInfo: {
       userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
       acceptHeader: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
       language: "nl-NL",
       colorDepth: 24,
       screenHeight: 723,
       screenWidth: 1536,
       timeZoneOffset: 0,
       javaEnabled: true
     },
     returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.."
   }

   // Send the request
   const checkoutAPI = new CheckoutAPI(client);
   const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });
   ```

   #### Go

   ```go
   // Adyen Go API Library v10.4.0
   import (
     "context"
     "github.com/adyen/adyen-go-api-library/v9/src/common"
     "github.com/adyen/adyen-go-api-library/v9/src/adyen"
     "github.com/adyen/adyen-go-api-library/v9/src/checkout"
   )
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   client := adyen.NewClient(&common.Config{
     ApiKey:      "ADYEN_API_KEY",
     Environment: common.TestEnv,
   })

   // Create the request object(s)
   amount := checkout.Amount{
     Currency: "EUR",
     Value: 1000,
   }

   googlePayDetails := checkout.GooglePayDetails{
     GooglePayToken: "STATE_DATA",
     Type: common.PtrString("googlepay"),
   }

   browserInfo := checkout.BrowserInfo{
     AcceptHeader: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
     ScreenWidth: 1536,
     JavaEnabled: true,
     ScreenHeight: 723,
     TimeZoneOffset: 0,
     UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
     Language: "nl-NL",
     ColorDepth: 24,
   }

   paymentRequest := checkout.PaymentRequest{
     Reference: "YOUR_ORDER_NUMBER",
     Amount: amount,
     MerchantAccount: "ADYEN_MERCHANT_ACCOUNT",
     PaymentMethod: checkout.GooglePayDetailsAsCheckoutPaymentMethod(&googlePayDetails),
     ReturnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..",
     BrowserInfo: &browserInfo,
   }

   // Send the request
   service := client.Checkout()
   req := service.PaymentsApi.PaymentsInput().IdempotencyKey("UUID").PaymentRequest(paymentRequest)
   res, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)
   ```

   #### Python

   ```py
   # Adyen Python API Library v12.5.1
   import Adyen

   adyen = Adyen.Adyen()
   adyen.client.xapikey = "ADYEN_API_KEY"
   # For the live environment, additionally include your liveEndpointUrlPrefix.
   adyen.client.platform = "test" # The environment to use library in.

   # Create the request object(s)
   json_request = {
     "merchantAccount": "ADYEN_MERCHANT_ACCOUNT",
     "reference": "YOUR_ORDER_NUMBER",
     "amount": {
       "currency": "EUR",
       "value": 1000
     },
     "paymentMethod": {
       "type": "googlepay",
       "googlePayToken": "STATE_DATA"
     },
     "browserInfo": {
       "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
       "acceptHeader": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
       "language": "nl-NL",
       "colorDepth": 24,
       "screenHeight": 723,
       "screenWidth": 1536,
       "timeZoneOffset": 0,
       "javaEnabled": True
     },
     "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy.."
   }

   # Send the request
   result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID")
   ```

   #### Ruby

   ```rb
   # Adyen Ruby API Library v9.5.1
   require "adyen-ruby-api-library"

   adyen = Adyen::Client.new
   adyen.api_key = 'ADYEN_API_KEY'
   # For the live environment, additionally include your liveEndpointUrlPrefix.
   adyen.env = :test # Set to "live" for live environment

   # Create the request object(s)
   request_body = {
     :merchantAccount => 'ADYEN_MERCHANT_ACCOUNT',
     :reference => 'YOUR_ORDER_NUMBER',
     :amount => {
       :currency => 'EUR',
       :value => 1000
     },
     :paymentMethod => {
       :type => 'googlepay',
       :googlePayToken => 'STATE_DATA'
     },
     :browserInfo => {
       :userAgent => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',
       :acceptHeader => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
       :language => 'nl-NL',
       :colorDepth => 24,
       :screenHeight => 723,
       :screenWidth => 1536,
       :timeZoneOffset => 0,
       :javaEnabled => true
     },
     :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..'
   }

   # Send the request
   result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' })
   ```

   #### NodeJS (TypeScript)

   ```ts
   // Adyen Node API Library v18.0.0
   // Require the parts of the module you want to use
   import { Client, CheckoutAPI, Types } from "@adyen/api-library";
   // Initialize the client object
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

   // Create the request object(s)
   const amount: Types.checkout.Amount = {
     currency: "EUR",
     value: 1000
   };

   const googlePayDetails: Types.checkout.GooglePayDetails = {
     googlePayToken: "STATE_DATA",
     type: Types.checkout.GooglePayDetails.TypeEnum.Googlepay
   };

   const browserInfo: Types.checkout.BrowserInfo = {
     acceptHeader: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
     screenWidth: 1536,
     javaEnabled: true,
     screenHeight: 723,
     timeZoneOffset: 0,
     userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
     language: "nl-NL",
     colorDepth: 24
   };

   const paymentRequest: Types.checkout.PaymentRequest = {
     reference: "YOUR_ORDER_NUMBER",
     amount: amount,
     merchantAccount: "ADYEN_MERCHANT_ACCOUNT",
     paymentMethod: googlePayDetails,
     returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..",
     browserInfo: browserInfo
   };

   // Send the request
   const checkoutAPI = new CheckoutAPI(client);
   const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });
   ```

   The response contains the result of the payment.

   **/payments response**

   ```json
   {
     "pspReference": "JDD6LKT8MBLZNN84",
     "resultCode": "Authorised"
   }
   ```

   If the shopper used a card that requires 3D Secure authentication before the payment can be completed, you receive an `action.type` **redirect** or `action.type` **threeDS2** in the response.

**/payments response for a card that requires 3D Secure authentication**

```json
{
      "resultCode": "RedirectShopper",
      "action": {
        "paymentMethodType": "scheme",
        "url": "https://test.adyen.com/hpp/3d/validate.shtml",
        "data": {
          "MD": "OEVudmZVMUlkWjd0MDNwUWs2bmhSdz09...",
          "PaReq": "eNpVUttygjAQ/RXbDyAXBYRZ00HpTH3wUosPfe...",
          "TermUrl": "https://example.com/checkout?shopperOrder=12xy..."
        },
        "method": "POST",
        "type": "redirect"
      }
    }
```

3. If you received an `action` object, use the information in this object to redirect the shopper to another website to complete the 3D Secure authentication. Otherwise, proceed to presenting the payment result to your shopper.

## Cards with 3D Secure: Handle the redirect

If the shopper used a card that requires 3D Secure authentication, you need to redirect the shopper to another website where they complete the authentication. To learn how to handle the redirect, follow our [Handling redirects guide](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#handle-the-redirect).

## Present the payment result

Use the `resultCode` that you received in the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) or [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) response to present the payment result to your shopper.\
The `resultCode` values you can receive for Google Pay are:

| resultCode     | Description                                              | Action to take                                                                                                                                   |
| -------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Authorised** | The payment was successful.                              | Inform the shopper that the payment has been successful.                                                                                         |
| **Error**      | There was an error when the payment was being processed. | Inform the shopper that there was an error processing their payment. The response contains a `refusalReason`, indicating the cause of the error. |
| **Refused**    | The payment was refused by the shopper's bank.           | Ask the shopper to try the payment again using a different payment method.                                                                       |

## Recurring payments

To make recurring Google Pay payments, you first need to [create a shopper token](/online-payments/tokenization/create-tokens) and then [make subsequent recurring transactions](/online-payments/tokenization/make-token-payments) with the token.\
Refer to [Tokenization](/online-payments/tokenization) for more information and detailed instructions.

## Test and go live

To start testing Google Pay, log in to a Google account and create a Google Pay wallet.

There are two approaches to using this wallet for testing:

* **Enroll in test card suite**

  Enroll your wallet in Google's [test card suite](https://developers.google.com/pay/api/android/guides/resources/test-card-suite). Test card suite pre-populates your wallet with a group of cards to use in the TEST environment. These are related to Adyen's collection of test cards, and cover scenarios including:

  * Cards stored as FPAN
  * Cards stored as DPAN (only when testing through native Android and Chrome on Android)
  * Cards enabled for 3DS2

  When you start the payment flow and open the list of test cards, each card is marked with the applicable scenario.

* **Without test card suite**

  You upload real credit cards to your wallet, which are mapped to one of Adyen's [test cards](/development-resources/test-cards-and-credentials/test-card-numbers) of the same brand. Your card is not charged.

  To test 3D Secure 2, you must use American Express or Discover cards, which trigger 3D Secure 2 challenge flows in the test environment. You cannot use any other card brands.

You can check the status of a Google Pay test payment in your [Customer Area](https://ca-test.adyen.com/) > **Transactions** > **Payments**, whether you used a card from the test card suite or or not. Remember that cards outside the test card suite are mapped to an Adyen test card of the same brand.

For more information, see Google Pay's test environment setup for [web](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist#about-the-test-environment) or for [Android](https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist#about-the-test-environment).

### Before you go live

1. Make sure that your API credential has the **API Clientside Encryption Payments role**. Check this in your [live Customer Area](https://ca-live.adyen.com/) or ask your Admin user to verify.

2. Make sure your [Google Merchant ID](https://developers.google.com/pay/api/web/reference/request-objects#MerchantInfo) is configured on Adyen. When you set up a Google Pay profile, Google assigns you a unique numeric code called a Merchant ID (MID). It is this MID that must be associated with your merchant account on Adyen.

   * In your [live Customer Area](https://ca-live.adyen.com/), go to **Settings** > **Payment methods**.

     If you do not see the **MID** column, select the gear icon and then enable the MID column.

3. Complete all the steps in the Google Pay API deploy to production documentation for [web](https://developers.google.com/pay/api/web/guides/test-and-deploy/deploy-production-environment) or for [Android](https://developers.google.com/pay/api/android/guides/test-and-deploy/deploy-your-application).

In production, Google Pay will only be available if:

* The shopper is logged in to their Google account.
* The shopper has at least one valid payment method on their Google Pay account.

## See also

* [API-only integration guide](/online-payments/api-only)
* [Google Pay API](https://developers.google.com/pay/api/)
* [Tokenization](/online-payments/tokenization)
* [Google Pay error codes](/development-resources/error-codes#google-pay-error-codes)
* [API Explorer](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/overview)
