Pesquisar

Are you looking for test card numbers?

Would you like to contact support?

Atenção, esta página não se encontra disponível em Português
Payment-method icon

Google Pay Component

Add Google Pay to an existing Components integration.

On this page, you can find additional configuration for adding Google Pay to your Components integration.

When shoppers select Google Pay, the Component presents the Google Pay payment sheet where shoppers choose a card they want to use. If shoppers select a card that requires 3D Secure authentication, the Component also handles redirecting shoppers to another website to complete the verification.

Before you begin

This page assumes you've already:

To be able to accept live Google Pay payments, you must complete all of the steps in Before you go live.

API reference

You don't need to send additional fields for Google Pay. To see optional fields that you can send for all payment methods, choose the endpoint you integrated:

Component configuration

Step 1: Load the Google Pay API JavaScript library

We recommend that you preload the the Google Pay API JavaScript library, by including the
following script in your checkout page:

<script src="https://pay.google.com/gp/p/js/pay.js"></script>

Step 2: Create a DOM element

Create a DOM element on your checkout page, placing it where you want the payment method form to be rendered:

 <div id="paywithgoogle-container"></div>

Step 3: Create an instance of the Component

Select which endpoint you're integrating:

This is the default with Components v5.0.0 or later.
There's no additional configuration you need to include for Google Pay. Use the create method of your AdyenCheckout instance, in this case checkout, to create the Component:
const googlePayComponent =  checkout.create('paywithgoogle');
If you implemented an advanced use case, or integrated Components before v5.0.0.
Parameter name Required Description
amount.value -white_check_mark- The value of the payment, in minor units.
amount.currency -white_check_mark- The currency code of the payment.
countryCode -white_check_mark- The two-letter country code of your merchant account.
environment -white_check_mark- Set to PRODUCTION when you're ready to accept live payments. The default value is TEST.
configuration.gatewayMerchantId Required for v3.12.0 or earlier The name of your Adyen merchant or company account.
configuration.merchantId Required for v3.12.0 or earlier Your Google Merchant ID.
allowedCardNetworks Required for v3.19.0 or earlier Specifies the card networks you support. Use the values from Google Pay.
The following example shows how to configure Components if you're using v3.12.0 or earlier.
Google Pay configuration
const googlePayConfiguration = {
    amount: {
        value: 1000,
        currency: "EUR"
    },
    countryCode: "NL",
    //Set this to PRODUCTION when you're ready to accept live payments
    environment: "TEST",
    //Reqired for v3.12.0 or earlier
    configuration: {
        gatewayMerchantId: "YOUR_ADYEN_COMPANY_OR_MERCHANT_ACCOUNT",
        //Your Google Merchant ID as described in https://developers.google.com/pay/api/web/guides/test-and-deploy/deploy-production-environment#obtain-your-merchantID
        merchantId: "YOUR_GOOGLE_MERCHANT_ID"
    },
    //Required for v3.19.0 or earlier. Use values from https://developers.google.com/pay/api/web/guides/tutorial#supported-card-networks
    allowedCardNetworks: ["AMEX", "MASTERCARD", "VISA"]
};
Use the create method of your AdyenCheckout instance, in this case checkout, to create the Component. Pass the configuration object if you created one:
const googlePayComponent = checkout.create('paywithgoogle', googlePayConfiguration);

Step 4: Mount the Component

Mount the Component only after checking that Google Pay is available to the shopper:

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

Optional configuration

You can also configure:

  • The merchant name that appears on the Google Pay payment sheet.
  • The Google Pay button appearance.
  • Your payment requirements.
  • The card types and payment methods that you accept.
  • Event handlers to use.

Merchant info

Configure the merchant name rendered in the payment sheet. See MerchantInfo for more details.
If you specify configuration.merchantName, then you must also specify configuration.merchantId and configuration.gatewayMerchantId.

Property Description
configuration.merchantName The merchant name you want displayed in the payment sheet.
configuration.gatewayMerchantId The name of your Adyen merchant or company account.
configuration.merchantId Your Google Merchant ID.

Button options

Configure the Google Pay button. See ButtonOptions for more details.

Property Description
buttonType The type of button you want displayed on your payments form. 
buttonColor The color of the button you want displayed on the payment form.
buttonLocale The language on the button. Defaults to the locale set on the current AdyenCheckout instance.
Supported from Web Components v4.1.0.
buttonSizeMode Specifies whether the button changes to fill the size of its container (the default), or has a static width and height.
Supported from Web Components v4.1.0.

Payment data

Configure your payment requirements. See PaymentDataRequest for more details.

Property Description
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 Set any shipping restrictions.
shippingOptionRequired Set to true if you want to present shipping options in the payment sheet.
shippingOptionParameters Set shipping options and a default shipping option to be shown in the payment sheet.

Card parameters

Configure accepted card types. See Card Parameters for more details.

Property Description
allowedAuthMethods Specify supported authentication methods. Default value is ['PAN_ONLY', 'CRYPTOGRAM_3DS'].
allowedCardNetworks Specify allowed card networks. From Web Components v3.20.0 the allowed networks are automatically configured based on your account settings, but you can override this here.
allowCreditCards Default is true. Set this to false if you don't support credit cards.
allowPrepaidCards Default is true. Set this to false if you don't support prepaid cards.
billingAddressRequired Set this to true if you require a billing address.
billingAddressParameters The expected fields returned if billingAddressRequired is set to true. For more information on the available fields, see Google Pay API documentation on billingAddressParameters.

Payment method support

Specify which payment methods are supported. See IsReadyToPayRequest for more details.

Property Description
existingPaymentMethodRequired Default is true.

Events

The following event handlers are supported for Google Pay.

Event Description
onClick(resolve, reject) Called when the shopper clicks the Google Pay button. Call resolve() or reject() to continue or stop the payment flow.
onChange or onSubmit Called after the shopper approves the payment on the Google Pay form. The first parameter (state) of this function contains all the necessary data to make a payment using the /payments API.
onAuthorized Called after the shopper approves the payment on the Google Pay form. Contains the full response from Google Pay. Use this if you need additional data such as the shipping address or the shopper email.

Recurring payments

To make recurring Google Pay payments, you first need to create a shopper token and then make subsequent recurring transactions with the token.

Refer to Tokenization for more information and detailed instructions.

Test and go live

To test Google Pay, you have two different options:

  • Login to a Google account and create a Google Pay wallet with valid card details.
  • Use a sample card from Google's test card suite .
Regardless of the option you use, Google Pay will replace the card number with the test card number starting with 4111 when you make a test payment. To test Google Pay with the 3D Secure flow, contact our Support Team.

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.

Before you go live

  1. Make sure your API credential has the API Clientside Encryption Payments role. Check this in your live Customer Area or ask your Admin user to verify.
  2. Contact our Support Team and submit a request to configure your Google Pay merchantID .
  3. Complete all of the steps in the Google Pay API deploy to production documentation for Web.

In the live environment, note that 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