Android Pay

Android Pay

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

Configuration

Add the following dependency to your build.gradle:

compile 'com.google.android.gms:play-services-wallet:10.0.0'

You can find detailed instructions in the Android Pay API guide.

Adding Android 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

Create a new AndroidPaySettings.

/* Create a new AndroidPaySettings with environment, public key, currency and amount */
AndroidPaySettings androidPaySettings = new AndroidPaySettings(
        WalletConstants.ENVIRONMENT_TEST,
        "public key",
        "USD",
        "9.99"
);

If you are using CheckoutActivity, add the AndroidPaySettings to the CheckoutSettings.

Set<String> paymentBrands = new HashSet<String>();
paymentBrands.add("ANDROIDPAY");

CheckoutSettings checkoutSettings = new CheckoutSettings(checkoutId, paymentBrands);
checkoutSettings.setAndroidPaySettings(androidPaySettings);

If you integrate Android Pay using our drop-in buttons, set the AndroidPaySettings.

PaymentButtonFragment paymentButtonFragment = new PaymentButtonFragment();

paymentButtonFragment.setPaymentBrand("ANDROIDPAY");
paymentButtonFragment.setAndroidPaySettings(androidPaySettings);

SDK & Your Own UI

Follow this tutorial to integrate the Android Pay into your UI. To make an Android Pay transaction you should simply provide a token received from Android Pay via AndroidPayPaymentParams.

PaymentParams paymentParams = new AndroidPayPaymentParams(checkoutId, token);