Search docs

Are you looking for test card numbers?

Would you like to contact support?

Start searching Adyen's documentation...

  Documentation

Google Pay

Learn how to accept Google Pay payments on POS terminals, on the web, and in Android apps.

Google Pay is a payment method that allows shoppers to make purchases using the card stored in their Google account. This provides them with a simpler checkout process whether they are buying from their Android devices, on the web, or in-store through POS terminals.

For more information on Google Pay availability, see Countries where you can use Google Pay and the list of Supported browsers.

Payment Type Payment flow Recurring Refunds Partial Refunds Captures Partial Captures Chargebacks
Wallet Direct Yes Yes Yes Yes Yes Yes

You can accept Google Pay payments with:

Prerequisites

Before you start with your Google Pay implementation, make sure that you:

  1. Read and understand our Web SDKAndroid SDK, or API integration guides.
  2. If you are using our API or have built your own UI for Android, read the  Google Pay API Setup and Tutorials documentation for Web  or Android.

Integrate with Web SDK

If you are using our  Web SDK, do the following steps first:

  1. Load the Google Pay API JavaScript library before initializing the Checkout SDK.

    <script src="https://pay.google.com/gp/p/js/pay.js"></script>
  2. Before you can start accepting live Google Pay payments, we need to configure your Google Pay merchantID. Follow Google Pay's Deploy production environment guidelines then contact Support Team and provide your merchantID from your Google Pay Developer Profile.

Integrate with Android SDK

If you are using our drop-in Android Checkout SDK, there is no need for additional configuration. 

If you have built your own UI for Android, you need to generate the Google Pay token then submit it to Adyen to complete the payment.

  1. Generate Google Pay token. Follow the Google Pay documentation to integrate your Android application. Set adyen as your gateway and provide your merchant account name in the gatewayMerchantId parameter.

    tokenizationSpecification.put(
          "parameters",
          new JSONObject()
              .put("gateway", "adyen")
              .put("gatewayMerchantId", "YourMerchantAccount"));

    Get the  token  from Google Pay API response PaymentData object  . 

  2. Include the Google Pay token when you  submit the payment .

    GooglePayDetails googlePayDetails = new GooglePayDetails.Builder(<YOUR_TOKEN_HERE>).build();
    mPaymentHandler.initiatePayment(googlePayPaymentMethod, googlePayDetails);

Integrate with API

To use our APIs for Google Pay transactions, you need to obtain a token from Google Pay and then pass the value to Adyen through a /payments request. 

Before you begin this section, make sure you read and understand our API Integration guide.

Step 1: Generate Google Pay token

You can get the Google Pay token from either:

Get the token from our Google Pay Component

To add the Google Pay Component to your payments form:

  1. Make sure that you have already added the Components JavaScript file and the required configuration on your payments page.

  2. Create a DOM element, placing it where you want the Google Pay button to be rendered: 

    <div id="googlepay"></div>
  3. Load the Google Pay API JavaScript library in your page: 

    <script src="https://pay.google.com/gp/p/js/pay.js"></script>
  4. Create an instance of the Google Pay Component, specifying: 

    • environment: Set to TEST. Change this to LIVE when you're ready to accept live Google Pay payments.
    • currencyCode: The three-character currency code.
    • amount
    • configuration.gatewayMerchantId: Your Adyen merchant account name.
    • configuration.merchantIdentifier: Your Google Merchant ID. This is optional for TEST payments. 
    const googlepay = checkout.create("paywithgoogle", {
        environment: "TEST",
        currencyCode: "EUR",
        amount: 1000,
        configuration: {
            gatewayMerchantId: "TestMerchant",
            merchantIdentifier: "12345678910111213141"
        },
        onChange: handleOnChange
    });
  5. Check whether Google Pay is available to the shopper. If it is, mount the Component:

    googlepay
        .isAvailable()
        .then(() => {
            googlepay.mount("#googlepay");
        })
        .catch(e => {
            // Google Pay is not available
        });

    Do not mount the Component if Google Pay is not available to the shopper.

  6. Create a function to listen to and handle the onChange event triggered by the Component:

    function handleOnChange(state, component) {
        state.isValid // true or false.
        state.data
        //  { type: "paywithgoogle", "paywithgoogle.token": "GOOGLEPAY_TOKEN" }
    }

    If there was an error during the authorization process an onError event is called.

    For more information on the paymentData response object, see Google's PaymentData documentation.

  7. When state.isValid is true, collect the values passed in the state.data. You'll use these to make the payment.

To configure how the Google Pay Component renders in your payment form, see Configuring the Component.

Get the token from your Google Pay API integration

Another option is to integrate directly with Google Pay directly to get your token. Follow the procedure on Google Pay documentation to integrate your Android application or your web application.

Set adyen as your gateway and provide your merchant account name in the gatewayMerchantId parameter.

tokenizationSpecification.put(
      "parameters",
      new JSONObject()
          .put("gateway", "adyen")
          .put("gatewayMerchantId", "YourMerchantAccount"));

After you have successfully completed the integration and handled the response object from Google Pay, get the token from PaymentData

Step 2: Make a payment

Make a /payments request, providing the: 

  • reference: Your unique reference for this payment.
  • amount
  • type: paywithgoogle
  • paywithgoogle.token: This is the token that you obtained from the Google Pay API response.
{
  "amount": {
    "currency": "USD",
    "value": 1000
  },
  "reference": "Your order number",
  "paymentMethod": {
    "type": "paywithgoogle",
    "paywithgoogle.token":"==Payload as retrieved from Google Pay response=="
  },
  "returnUrl": "https://your-company.com/...",
  "merchantAccount": "YourMerchantAccount"
}

If the payment was successful, you'll receive an authorised resultCode and a pspReference, which is our unique identifier for this payment.

If the shopper used a card with 3D Secure enabled, you will get the resultCode redirectShopper. Follow the steps for Cards with 3D Secure to redirect the shopper and to complete the redirect payment.

Step 3: Present payment result

Use the resultCode you received from the /payments endpoint to present the shopper with a the result of the payment via your website or app. Check our result codes documentation for information on what these mean, and what actions you should take.

Integrate with POS

Google Pay is supported out-of-the-box on our POS terminals without  any additional integration effort.

Shoppers using an Android phone with NFC may use Google Pay when purchasing in-store in countries where POS is available.  

Google Pay notifications

Accepting notifications is required for Google Pay. Know the status of the transaction through notifications

Each notification has a pspReference that you can use to identify the transaction and an Event codes that indicates the transaction status.

Configuring the Component

  • Create an instance of the Google Pay Component, specifying: 

  • You can also configure the following Google Pay API parameters in your Google Pay Component:

    • emailRequired: Set this to true if you want to collect the shopper's email address. 
    • shippingAddressRequired: Set to true to request the shopper's full shipping address. 
    • shippingAddressParameters: Used to set any shipping restrictions.

      The following configuration options are supported from Components version 2.2.0 and later.

    • allowedAuthMethods: Specify supported authentication methods. Default value is ['PAN_ONLY', 'CRYPTOGRAM_3DS'].
    • allowedCardNetworks: Specify allowed card networks. Default value is ['AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA'].
    • existingPaymentMethodRequired: Default is true.
    • allowPrepaidCards: Default is true. Set this to false if you don't support prepaid cards.
    • billingAddressRequired: Set this to true if a billing address required to process the transaction.
    • billingAddressParameters: The expected fields returned if billingAddressRequired is set to true. See Google Pay API billingAddressParameters.
    const googlepay = checkout.create("paywithgoogle", {
        ...
    
        // Options
        configuration: {
            ...
            merchantName: "YourMerchantName"
        },
        emailRequired: true,
        shippingAddressRequired: true,
        shippingAddressParameters: {},
        buttonType: "long",
        buttonColor: "default"
    });

Testing Google Pay payments

To test Google Pay, you must:

  • Login to a real Google account.
  • Create a Google Pay wallet with valid card details. Google Pay does not accept test cards.

You can check the status of a Google Pay test payment in your Customer Area > Transactions > Payments.

For more information, see Google Pay's test environment setup for Web or for Android.

Go live checklist

Start accepting live Google Pay payments once you have performed the following:

Google Pay will be available in production mode 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