PaymentsClient

  • PaymentsClient is a client for interacting with the Google Pay API.

  • It provides methods to recognize payment cards, get payment metadata, check if a user is ready to pay, and load payment data.

  • The methods typically return a Task that resolves with the requested data or a response indicating success.

  • Some methods utilize the AutoResolveHelper to handle exceptions and pipe results to Activity.onActivityResult.

public classPaymentsClient extendsGoogleApi<Wallet.WalletOptions>

Client for interacting with the Google Pay API. SeeGoogleApi for details about how the connection between your app and Google Play services is managed.

Public Method Summary

Task<PaymentCardRecognitionIntentResponse>
getPaymentCardRecognitionIntent(PaymentCardRecognitionIntentRequest request)
Requests aPendingIntent of the Google payment card recognition Activity to perform card recognition action.
Task<PaymentMetadata>
getPaymentMetadata(PaymentMetadataRequest request)
RequestsPaymentMetadata, which contains select payment method data useful to inform the user that they are able to make a payment.
Task<Boolean>
isReadyToPay(IsReadyToPayRequest request)
Determines if the user can make payments using the Google Pay API.
Task<PaymentData>
loadPaymentData(PaymentDataRequest request)
RequestsPaymentData, which contains the necessary information to complete a payment.

Inherited Method Summary

From class com.google.android.gms.common.api.GoogleApi
String
getApiFallbackAttributionTag(Context arg0)
From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

Public Methods

public Task<PaymentCardRecognitionIntentResponse>getPaymentCardRecognitionIntent(PaymentCardRecognitionIntentRequest request)

Requests aPendingIntent of the Google payment card recognition Activity to perform card recognition action.

This API checks the following minimum requirements to finish a transaction using the Google Pay API:

Note that the requirements mentioned above are not exhaustive and can change over time.

When the Google payment card recognition Activity successfully recognizes a payment card and returns anIntent through Activity.onActivityResult(int, int, Intent), your app should call PaymentCardRecognitionResult.getFromIntent(Intent) to extract the result.

Parameters
requestAn instance of PaymentCardRecognitionIntentRequest used to specify additional settings.

public Task<PaymentMetadata>getPaymentMetadata(PaymentMetadataRequest request)

RequestsPaymentMetadata, which contains select payment method data useful to inform the user that they are able to make a payment.

This API conforms to the protocol defined byAutoResolveHelper. Instead of handling the returned exceptions yourself (i.e.ResolvableApiException), you should use theAutoResolveHelper to pipe the results back to Activity.onActivityResult(int, int, android.content.Intent).

Parameters
requestAn instance ofPaymentMetadataRequest used to specify additional settings.

public Task<Boolean>isReadyToPay(IsReadyToPayRequest request)

Determines if the user can make payments using the Google Pay API. We recommend to call this method before showing an option to pay using the Google Pay API.

    This API checks the following minimum requirements to finish a transaction using the Google Pay API:
  • Device is running on a supported Android system version and also has a supported version of Google Play services installed.
  • Google Pay API has launched in the user's country.
  • User either has or can add a card in flow according to the specifications given in theIsReadyToPayRequest.

Note that the requirements mentioned above are non-exhaustive and may change over time.

Parameters
requestAn instance ofIsReadyToPayRequest used to specify additional filtering criteria.

public Task<PaymentData>loadPaymentData(PaymentDataRequest request)

RequestsPaymentData, which contains the necessary information to complete a payment.

Note that this action will generally require UI to be shown to the users so they can select a payment method.

This API conforms to the protocol defined byAutoResolveHelper. Instead of handling the returned exceptions yourself when the Google Pay payment sheet needs to be shown (i.e.ResolvableApiException), you should use theAutoResolveHelper to pipe the results back to Activity.onActivityResult(int, int, android.content.Intent). This implementation frees your code from having to receive the result differently depending on the display of the Google Pay payment sheet.

Parameters
requestAn instance ofPaymentDataRequest used to specify additional settings.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-01 UTC.