Payment for Google Pay

Payment using the Android SDK can be taken from cards registered in Android Pay Wallet, as well as ones you have used for previous transactions but which are not registered with wallet (known as Card on File with Google). After clicking the 'Pay' button:

  1. Choose your Google account from the list displayed
  2. Choose the card from the list displayed, which is one of the following:
    • Cards registered with Android Pay and cards on file
    • Cards on file only
    • An empty list, because no cards are associated with the account

Apart from payment using Android Pay or cards on file, you can also accept a standard mobile payment from Android devices, in which the user enters card information directly on their mobile device.

Configuring Parameters

Merchants must configure support for specific payment methods. The following flags are used to map payment methods in the Android SDK:

Android Pay Card


Card on File with Google


You can select either Card on File or both payment methods, depending on whether you are in one of the countries in which Paysafe supports Android Pay.

Initiating a Payment for Google Pay

  1. Set up an instance of PaymentsClient in your Activity for interacting with Google Pay.
    This procedure integrates with Google Pay, which helps retrieve the payload for the card (which is associated with the consumer's Google account, including those cards tokenized for Android Pay). For testing the integration you can set the environment as follows: WalletConstants.ENVIRONMENT_TEST
PaymentsClient paymentsClient = Wallet.getPaymentsClient(this,
         new Wallet.WalletOptions.Builder()
  1. Call isReadyToPay() to check whether Google Pay is supported on the device.
    In this step we set up payment methods that will be supported within your application. In the method isReadyToPay(), we set parameters for addAllowedPaymentMethod which in turn sets flags for the corresponding supported payment methods.
    If the flag WalletConstants.PAYMENT_METHOD_CARD is set, the user will be presented only with cards that are on file, and not with cards registered with Android Pay.
    If the flag WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD is set then the user is presented with cards registered for Android Pay.
    You can add both payment methods if you are in a country where Paysafe supports Android Pay.
    If the device does not support Google Pay, the customer must use the traditional method of making a mobile payment, which involves entering card details on the mobile device.
 * IsReadyToPay
private void isReadyToPay() {
    IsReadyToPayRequest request = IsReadyToPayRequest.newBuilder()
            .addAllowedPaymentMethod( WalletConstants.PAYMENT_METHOD_CARD)
            .addAllowedPaymentMethod( WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD)
    Task <Boolean> task = paymentsClient.isReadyToPay(request);
            new OnCompleteListener<Boolean>() {
                public void onComplete( Task<Boolean> task) {
                    try {
                        boolean result =
                                task.getResult( ApiException.class);
                        if(result == true) {
                            // LOG
                            Utils.debugLog("IsReadyToPay Result: True");

                            // Google Payment supported on device
                            //show Google as payment option

                            // Define this ArrayList<Integer> in your class and instantiate it
                            // to use below to set flag for payment method options
                            flagPaymentMethods = new ArrayList<Integer>();

                            // CHECK, if device supports NFC
                            // if YES, show below payment methods
                            // 1. Card on file
                            // 2. Android Pay
                            if (Utils.isNFCAvailable(PaysafeApplication.mApplicationContext)) {
                                // LOG
                                Utils.debugLog("Payment Method: card_on_file and android_pay");

                                // set payment methods
                                flagPayWithGoogle = WalletConstants.PAYMENT_METHOD_CARD;
                                flagAndroidPay = WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD;
                                // Add Options to Payment Methods

                            else {
                                // LOG
                                Utils.debugLog("Payment Method: card_on_file");
                                // if NO (device does'nt support NFC), show below payment methods
                                // 1. Card on file
                                flagPayWithGoogle = WalletConstants.PAYMENT_METHOD_CARD;
                                // Add Options to Payment Methods


                        } else {
                            // LOG
                            Utils.debugLog("IsReadyToPay Result: False");

                            // Google Payment not supported on device
                            //hide Google as payment option
                            Utils.showDialogAlert("Google Payment Option Not Supported!",

                    } catch (ApiException exception) {
} // end of isReadyToPay()
  1. Clicking BUY creates a PaymentDataRequest object and calls the loadPaymentData API. The PaymentDataRequest object is parseable and represents a payment data request containing the information necessary for a payment.
        new View .OnClickListener() {
              public void onClick( View view) {
                         PaymentDataRequest request = createPaymentDataRequest ();
                         if (request != null) {
                                   AutoResolveHelper .resolveTask( paymentsClient.loadPaymentData(request), this,
  1. Set the PaymentMethodTokenizationParameters as follows:
PaymentMethodTokenizationParameters params =
        .addParameter("gateway", "paysafe")
        .addParameter("gatewayMerchantId", "yourMerchantIdGivenFromYourGateway")
  1. Add Payment Method Tokenization Parameters in the Payment Data Request, as per the WalletConstants in step 2 above.
 * CreatePaymentDataRequest
private PaymentDataRequest createPaymentDataRequest() {
    PaymentDataRequest .Builder request =
            PaymentDataRequest .newBuilder()
                            WalletConstants .PAYMENT_METHOD_CARD)
                            WalletConstants .PAYMENT_METHOD_TOKENIZED_CARD)

} // end of createPaymentDataRequest()

Making the Payment

  1. Click the Google Pay button.
  1. If Google Pay is supported, the consumer will be able to choose their card (either a card on file or a tokenized card where Paysafe supports Android Pay).

  1. Click Continue. The payment bundle will be requested using the card selected.

When you confirm the payment, the SDK communicates with the Paysafe Customer Vault API server to get a single-use token. The single-use token can then be used my the merchant server for an authorization or purchase request calling the Paysafe Card Payments API.

Did you find this page useful?