Google Pay

Google Pay

The Google Pay offers a quick and easy path to enable secure, one touch payments in your app.
This guide explains how to process payments with our SDK.


  • A Mobile SDK integration (Ready-to-Use UI or SDK & Your Own UI)
  • A Google account, when you're ready to deploy your Google Pay integration, sign-up to get access and test with production credentials.


Open the build.gradle file in the app module and add the following to the dependencies block:

dependencies {
    implementation ''
    implementation ''

Adding the Google Pay to your app must be done in one of two ways, depending on whether you are using the Ready-to-Use UI or the SDK & Your Own UI. These two ways are covered in the sections below. Please follow the instructions relevant to the approach you have chosen.

Ready-to-Use UI


Add the following line to your file:

-keep class** { *; }

Add GOOGLEPAY payment brand

Create the CheckoutSettings, and add the GOOGLEPAY to the payment brands list:

Set<String> paymentBrands = new HashSet<String>();

CheckoutSettings checkoutSettings = new CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST);

If you integrate the Google Pay using our drop-in buttons, set the GOOGLEPAY payment brand in the PaymentButtonFragment.


Configure PaymentDataRequest

Create PaymentDataRequest to configure Google Pay widget with the transaction info, allowed payment methods and card networks.
Use GooglePayHelper method to easily create base PaymentDataRequest.Builder with all required parameters.

Then you can add some optional configurations, e.g. enable requesting shipping info in the widget. Please refer to the Google Pay Payments API documentation for more options.

Integer[] paymentMethods = new Integer[] {

Integer[] cardNetworks = new Integer[] {

PaymentDataRequest.Builder paymentDataRequestBuilder = GooglePayHelper.preparePaymentDataRequestBuilder(

Call build() method to get a final configuration object and pass it to the CheckoutSettings.


Collecting shopper information

You can collect additional information with the Google Pay widget before submitting the transaction, e.g. shipping information.

Configure payment data request

In addition to the previous steps complete configuration of the PaymentDataRequest.Builder object to request additional information from the shopper. Refer to the Payments API to see the full list of options.


Configure receiving callbacks from the checkout

The CheckoutActivity may send the callback CheckoutActivity.ACTION_ON_BEFORE_SUBMIT when shopper submits the payment.
To receive it you should complete the following steps:

1. Create your broadcast receiver to listen the intents from CheckoutActivity.
See below how to receive PaymentData object with the requested data from the Google Pay widget. Refer to the Payments API for the class definition.

public class CheckoutBroadcastReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (CheckoutActivity.ACTION_ON_BEFORE_SUBMIT.equals(action)) {
            /* Collect shopper information from the Google Pay */
            PaymentData paymentData = intent.getParcelableExtra(CheckoutActivity.EXTRA_GOOGLE_PAY_PAYMENT_DATA);

            String paymentBrand = intent.getStringExtra(CheckoutActivity.EXTRA_PAYMENT_BRAND);
            String checkoutId = intent.getStringExtra(CheckoutActivity.EXTRA_CHECKOUT_ID);
            ComponentName senderComponentName = intent.getParcelableExtra(CheckoutActivity.EXTRA_SENDER_COMPONENT_NAME);

            /* Return control back to the CheckoutActivity to submit the payment */
            Intent checkoutIntent = new Intent(CheckoutActivity.ACTION_ON_BEFORE_SUBMIT);
            checkoutIntent.putExtra(CheckoutActivity.EXTRA_CHECKOUT_ID, checkoutId);


2. Declare your broadcast receiver in AndroidManifest.xml.

    android:exported="false" />

NOTE: It is important to set android:exported="false" to your broadcast receiver. In this case the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID.

3. To provide the best security our SDK uses directed broadcasts. This way our broadcast is received only by the specified BroadcastReceiver. For this reason you should add ComponentName of your receiver to CheckoutActivity intent.

CheckoutSettings settings = new CheckoutSettings(...);
ComponentName receiverComponentName = new ComponentName("yourPackageName", "yourReceiverClassName");
Intent intent = checkoutSettings.createCheckoutActivityIntent(this, receiverComponentName);

startActivityForResult(intent, CheckoutActivity.REQUEST_CODE_CHECKOUT);

Confirmation page

Google Pay Confirmation Page

A final price must be displayed to the shopper before processing the transaction. If the amount to be charged has varied based on data received from the Google Pay widget you are expected to show a confirmation page with a final price. You can configure it in CheckoutActivity.ACTION_ON_BEFORE_SUBMIT callback.

1. Initialize OrderSummary object with order details, total amount and Google Pay PaymentData response object.

PaymentData paymentData = intent.getParcelableExtra(CheckoutActivity.EXTRA_GOOGLE_PAY_PAYMENT_DATA);

if (paymentData != null) {
    LinkedHashMap orderItems = new LinkedHashMap() {{
        put("Subtotal", 200.00);
        put("Shipping", 10.00);

    OrderSummary orderSummary = new OrderSummary(orderItems, 210.00, paymentData);

2. Add OrderSummary extra to the CheckoutActivity intent.

checkoutIntent.putExtra(CheckoutActivity.EXTRA_ORDER_SUMMARY, orderSummary);

3. Start checkout activity to return control back to the sdk and show confirmation page.

SDK & Your Own UI

Follow this tutorial to integrate the Google Pay into your UI.
Use the following parameters:

gateway = "aciworldwide"
gatewayMerchantId = "YOUR_ENTITY_ID"
To make a transaction create the GooglePayPaymentParams with a received token:

PaymentParams paymentParams = new GooglePayPaymentParams(checkoutId, token);

And submit the transaction:

Transaction transaction = null;

try {
    transaction = new Transaction(paymentParams);
} catch (PaymentException ee) {
    /* error occurred */