Are you looking for test card numbers?

Would you like to contact support?

No momento, esta página não está disponível em português
Payment-method icon

Google Pay Component

Add Google Pay to an existing Components integration.

Our Google Pay Component renders Google Pay in your payment form. When the shopper selects Google Pay, Drop-in invokes the payment sheet, where shoppers select the card they want to use, and completes the payment.

When building your Google Pay integration, you also need to handle the redirect if the the shopper makes a payment with a card that requires 3D Secure authentication.

Before you begin

Before starting your Google Pay integration:

  1. Build a Components integration.
  2. Follow the setup steps in the Google Pay documentation.
  3. Add Google Pay in your Customer Area.

Show Google Pay in your payment form

To show Google Pay Component in your payment form, you need to:

  1. Specify in your /paymentMethods request:

  2. Deserialize the response from the /paymentMethods call and get the object with type: googlepay.

  3. Add the Google Pay Component:

    a. Import the Google Pay Component to your build.gradle file.

    implementation "com.adyen.checkout:googlepay:<latest-version>"

    Check the latest version on GitHub.

    b. Create a GooglePayConfiguration object, passing your client key. You can also include optional configuration, for example to add the amount on the Pay button.

    val amount = Amount()
       // Optional. In this example, the amount is 10 EUR.
        amount.currency = "EUR"
        amount.value = 10_00
    
    val googlePayConfig = GooglePayConfiguration.Builder(YourContext, "YOUR_CLIENT_KEY")
       .setAmount(amount)
       // When you're ready to accept live payments, change the value to one of our live environments (for example, Environment.LIVE).
       .setEnvironment(Environment.TEST)
       // Required for versions earlier than v4.5.0. When you're ready to accept live payments, change the value to ENVIRONMENT_PRODUCTION.
       .setGooglePayEnvironment(WalletConstants.ENVIRONMENT_TEST)
       .build()

    c. Check if Google Pay is available on the shopper's device. If available, initialize the Component and present a Google Pay button according to Google Pay specifications.

    var googlePayComponent: GooglePayComponent
    GooglePayComponent.PROVIDER.isAvailable(application, paymentMethod, googlePayConfiguration) {
            isAvailable: Boolean, paymentMethod: PaymentMethod, config: GooglePayConfiguration? ->
        if (isAvailable) {
            googlePayButton.visibility = View.VISIBLE
            googlePayComponent = GooglePayComponent.PROVIDER.get(YourContext, paymentMethod, googlePayConfiguration)
        }
    }

    d. When the shopper selects the Google Pay button, call startGooglePayScreen.

    googlePayComponent.startGooglePayScreen(YourContext, googlePayRequestCode)

    e. Pass the result to the Component, and wait to be notified by the observer.

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == googlePayRequestCode) {
            googlePayComponent.observe(YourContext) { googlePayComponentState ->
                if (googlePayComponentState?.isValid == true) {
                    // When the shopper proceeds to pay, pass the `paymentComponentState.data` to your server to send a /payments request
                    sendPayment(googlePayComponentState.data)
                }
            }
            googlePayComponent.handleActivityResult(resultCode, data)
        }
    }

Make a payment

When the shopper proceeds to pay, the Component returns the paymentComponentState.data.paymentMethod.

  1. Pass the paymentComponentState.data.paymentMethod to your server.
  2. From your server, make a /payments request, specifying:

    • paymentMethod.type: The paymentComponentState.data.paymentMethod from your client app.
    • browserInfo: Required if you want to trigger 3D Secure authentication.
    • returnURL: URL where the shopper will be redirected back to after completing a 3D Secure authentication. Get this URL from the Component in the RedirectComponent.getReturnUrl(context).
    curl https://checkout-test.adyen.com/v68/payments \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
      "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
      "reference":"YOUR_ORDER_NUMBER",
      "amount":{
        "currency":"EUR",
        "value":1000
      },
      "{hint:data from your client app}paymentMethod{/hint}":{
        "type":"googlepay",
        "googlePayToken": "{\"signature\":\"MEUCIFNbi10fa\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"u4YsMQ4i56lTS..D+2m9vYwY\\\",\\\"ephemeralPublicKey\\\":\\\"BIwdzX4a+rC1DiKY6/8Y\\\\u003d\\\",\\\"tag\\\":\\\"pe0MF+z7\\\\u003d\\\"}\"}"
      },
      "{hint:Required for 3D Secure}browserInfo{/hint}: {
          "userAgent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
          "acceptHeader":"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"
      },
      "returnUrl":"adyencheckout://your.package.name"
    }'
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen::Client.new
    adyen.api_key = "YOUR_X-API-KEY"
     
    response = adyen.checkout.payments({
      :amount => {
        :currency => "EUR",
        :value => 1000
      },
      :reference => "YOUR_ORDER_NUMBER",
      :paymentMethod => {
        :type => "googlepay",
        :googlePayToken => "{\"signature\":\"MEUCIFNbi10fa\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"u4YsMQ4i56lTS..D+2m9vYwY\\\",\\\"ephemeralPublicKey\\\":\\\"BIwdzX4a+rC1DiKY6/8Y\\\\u003d\\\",\\\"tag\\\":\\\"pe0MF+z7\\\\u003d\\\"}\"}"
      },
      :browserInfo => {
        :userAgent => "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
        :acceptHeader => "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"
      },
      :returnUrl => "adyencheckout://your.package.name",
      :merchantAccount => "YOUR_MERCHANT_ACCOUNT"
    })
    // Set YOUR_X-API-KEY with the API key from the Customer Area.
    // Change to Environment.LIVE and add the Live URL prefix when you're ready to accept live payments.
        Client client = new Client("YOUR_X-API-KEY", Environment.TEST);
        Checkout checkout = new Checkout(client);
    
        PaymentsRequest paymentsRequest = new PaymentsRequest();
    
        String merchantAccount = "YOUR_MERCHANT_ACCOUNT";
        paymentsRequest.setMerchantAccount(merchantAccount);
    
        Amount amount = new Amount();
        amount.setCurrency("EUR");
        amount.setValue(15000L);
        paymentsRequest.setAmount(amount);
    
        GooglePayDetails googlePayDetails = new GooglePayDetails();
    
        googlePayDetails.setGooglePayToken(state.data.paymentMethod.googlePayToken);
        paymentsRequest.setPaymentMethod(googlePayDetails);
    
        BrowserInfo browserInfo = new BrowserInfo();
        browserInfo.setUserAgent("Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36");
        browserInfo.setAcceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
    
        paymentsRequest.setBrowserInfo(browserInfo);
    
        paymentsRequest.setReference("YOUR_ORDER_NUMBER");
        paymentsRequest.setReturnUrl("adyencheckout://your.package.name");
    
        PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    $client = new \Adyen\Client();
    $client->setXApiKey("YOUR_X-API-KEY");
    $service = new \Adyen\Service\Checkout($client);
    
    $params = array(
      "amount" => array(
        "currency" => "EUR",
        "value" => 1000
      ),
      "reference" => "YOUR_ORDER_NUMBER",
      "paymentMethod" => array(
        "type" => "googlepay",
        "googlePayToken" => "{\"signature\":\"MEUCIFNbi10fa\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"u4YsMQ4i56lTS..D+2m9vYwY\\\",\\\"ephemeralPublicKey\\\":\\\"BIwdzX4a+rC1DiKY6/8Y\\\\u003d\\\",\\\"tag\\\":\\\"pe0MF+z7\\\\u003d\\\"}\"}"
      ),
      "browserInfo" => [
        "userAgent" => "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
        "acceptHeader" => "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"
      ],
      "returnUrl" => "adyencheckout://your.package.name",
      "merchantAccount" => "YOUR_MERCHANT_ACCOUNT"
    );
    $result = $service->payments($params);
    #Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    result = adyen.checkout.payments({
       'amount': {
          'value': 1000,
          'currency': 'EUR'
       },
       'reference': 'YOUR_ORDER_NUMBER',
       'paymentMethod': {
          'type': 'googlepay',
          'googlePayToken': '{\"signature\":\"MEUCIFNbi10fa\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"u4YsMQ4i56lTS..D+2m9vYwY\\\",\\\"ephemeralPublicKey\\\":\\\"BIwdzX4a+rC1DiKY6/8Y\\\\u003d\\\",\\\"tag\\\":\\\"pe0MF+z7\\\\u003d\\\"}\"}'
       },
       'browserInfo': {
          'userAgent': 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36',
          'acceptHeader': 'text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8'
       },
       'returnUrl': 'adyencheckout://your.package.name',
       'merchantAccount': 'YOUR_MERCHANT_ACCOUNT'
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    var client = new Client ("YOUR_X-API-KEY", Environment.Test);
    var checkout = new Checkout(client);
    
    var amount = new Adyen.Model.Checkout.Amount("EUR", 1000);
    var details = new GooglePayDetails{
      Type = "googlepay",
      GooglePayToken = "{\"signature\":\"MEUCIFNbi10fa\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"u4YsMQ4i56lTS..D+2m9vYwY\\\",\\\"ephemeralPublicKey\\\":\\\"BIwdzX4a+rC1DiKY6/8Y\\\\u003d\\\",\\\"tag\\\":\\\"pe0MF+z7\\\\u003d\\\"}\"}"
    };
    var browserInfo  = new Adyen.Model.Checkout.BrowserInfo{
      UserAgent = @"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
      AcceptHeader = @"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"
    };
    var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
    {
      Reference = "YOUR_ORDER_NUMBER",
      Amount = amount,
      ReturnUrl = @"adyencheckout://your.package.name",
      MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
      PaymentMethod = details,
      BrowserInfo = browserInfo
    };
    
    var paymentResponse = checkout.Payments(paymentsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
    const config = new Config();
    // Set your X-API-KEY with the API key from the Customer Area.
    config.apiKey = '[API_KEY]';
    config.merchantAccount = '[YOUR_MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    checkout.payments({
        amount: { currency: "EUR", value: 1000 },
        paymentMethod: {
            type: 'googlepay',
            googlePayToken: '{\"signature\":\"MEUCIFNbi10fa\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"u4YsMQ4i56lTS..D+2m9vYwY\\\",\\\"ephemeralPublicKey\\\":\\\"BIwdzX4a+rC1DiKY6/8Y\\\\u003d\\\",\\\"tag\\\":\\\"pe0MF+z7\\\\u003d\\\"}\"}'
        },
        browserInfo: {
            userAgent: 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36',
            acceptHeader: 'text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8'
        },
        reference: "YOUR_ORDER_NUMBER",
        merchantAccount: config.merchantAccount,
        returnUrl: "adyencheckout://your.package.name"
    }).then(res => res);

    The response contains the result of the payment.

    /payments response
    {
      "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 in the response.

    /payments response for a card that requires 3D Secure authentication
      {
        "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"
        }
      }
  1. Pass the action object to your client app. You need this to initialize the Redirect Component.

Cards with 3D Secure: Handle the redirect

If the shopper makes a payment with a card that requires 3D Secure authentication, use the Redirect Component to redirect the shopper to another website to complete the authentication. After the shopper returns to your app, make a POST /payments/details request from your server, providing:

  • details: The actionComponentData.details object from the Redirect Component.

/payments/details request
curl https://checkout-test.adyen.com/v68/payments/details \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
     "details": {
       "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ=="
   }
}'

You receive a response containing:

  • resultCode: Use this to present the payment result to your shopper.
  • pspReference: Our unique identifier for the transaction.

/payments/details response
{
      "resultCode": "Authorised",
      "pspReference": "PPKFQ89R6QRXGN82"
}

Present the payment result

Use the resultCode that you received in the /payments or /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 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, log in to a Google account and create a Google Pay wallet with the details of a real card, not a test card. When you make a test payment, the card number is automatically mapped to our test card number starting with 4111, so the real card is not charged.

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 for Android.

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. Go to your live Customer Area to configure your Google Merchant ID.
  3. Complete all the steps in the Google Pay API deploy to production documentation for Android.

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