Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

close

- - Get Started
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
    - Get the SDK
  - Google Services
- - Google Play
  - Publishing
  - Promoting
  - App Quality
  - Spotlight
  - Open Distribution

## Results

Loading...
Summary: Ctors | Methods | Inherited Methods | [Expand All]
public class

# WalletClient

extends Object
implements GooglePlayServicesClient

java.lang.Object
↳ | com.google.android.gms.wallet.WalletClient

This class is deprecated.
Use `GoogleApiClient` and `Wallet` instead.

## Class Overview

The main entry point for Google Wallet integration. Use the WalletClient after the asynchronous `connect()` method has been called and your listener's `onConnected(Bundle)` method is called.

When your app is done using WalletClient, call `disconnect()`, even if the async result from `connect()` has not yet been delivered.

You should instantiate this object in your Activity's `onCreate(Bundle)` method and then call `connect()` in `onStart()` and `disconnect()` in `onStop()`, regardless of the state.

To allow the user to select and change the account associated with the transaction and Google transaction ID, use `null` for the accountName parameter of the constructor. No special action is required when a user changes the selected account through the UI in this case, and the Google transaction ID associated with the transaction can continue to be used.

To specify the account and prevent the user from selecting another account, pass the account through the accountName parameter. To change the account, construct a new WalletClient with the new account and do not reuse the Google transaction ID associated with the old account - this is a new transaction.

We recommend that you apply for API access at http://getinstantbuy.withgoogle.com/ before starting development. During development, use the sandbox environment by specifying `ENVIRONMENT_SANDBOX` in the constructor.

## Summary

Public Constructors
| WalletClient(Activity activity, int environment, String accountName, GooglePlayServicesClient.ConnectionCallbacks connectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener) Creates a Google Wallet client to connect to Google Play services.
| WalletClient(Activity activity, int environment, String accountName, int theme, GooglePlayServicesClient.ConnectionCallbacks connectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener) Creates a Google Wallet client to connect to Google Play services.

Public Methods
void | changeMaskedWallet(String googleTransactionId, String merchantTransactionId, int requestCode) This method brings up a Google Wallet selector screen to allow your customer to select a new payment instrument or shipping address from their Google Wallet.
void | checkForPreAuthorization(int requestCode) This API checks to see if a user has previously authorized the application to access their Wallet account.
void | connect() Connects the client to Google Play services.
void | disconnect() Closes the connection to Google Play services.
boolean | isConnected() Checks if the client is currently connected to the service, so that requests to other methods will succeed.
boolean | isConnecting() Checks if the client is attempting to connect to the service.
boolean | isConnectionCallbacksRegistered(GooglePlayServicesClient.ConnectionCallbacks listener) Returns true if the specified listener is currently registered to receive connection events.
boolean | isConnectionFailedListenerRegistered(GooglePlayServicesClient.OnConnectionFailedListener listener) Returns true if the specified listener is currently registered to receive connection failed events.
void | loadFullWallet(FullWalletRequest request, int requestCode) Requests a `FullWallet`, which contains the payment credentials.
void | loadMaskedWallet(MaskedWalletRequest request, int requestCode) If an application has authorization, loadMaskedWallet() allows you to skip the Google Wallet selector and directly request the masked payment credentials.
void | notifyTransactionStatus(NotifyTransactionStatusRequest request) Sends a notification to Google on whether the transaction succeeded or failed.
void | registerConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks listener) Registers a listener to receive connection events from this `GooglePlayServicesClient`.
void | registerConnectionFailedListener(GooglePlayServicesClient.OnConnectionFailedListener listener) Registers a listener to receive connection failed events from this `GooglePlayServicesClient`.
void | unregisterConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks listener) Removes a connection listener from this `GooglePlayServicesClient`.
void | unregisterConnectionFailedListener(GooglePlayServicesClient.OnConnectionFailedListener listener) Removes a connection failed listener from the `GooglePlayServicesClient`.

[Expand] Inherited Methods

From class java.lang.Object

Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

From interface com.google.android.gms.common.GooglePlayServicesClient

abstract void | connect() Connects the client to Google Play services.
abstract void | disconnect() Closes the connection to Google Play services.
abstract boolean | isConnected() Checks if the client is currently connected to the service, so that requests to other methods will succeed.
abstract boolean | isConnecting() Checks if the client is attempting to connect to the service.
abstract boolean | isConnectionCallbacksRegistered(GooglePlayServicesClient.ConnectionCallbacks listener) Returns true if the specified listener is currently registered to receive connection events.
abstract boolean | isConnectionFailedListenerRegistered(GooglePlayServicesClient.OnConnectionFailedListener listener) Returns true if the specified listener is currently registered to receive connection failed events.
abstract void | registerConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks listener) Registers a listener to receive connection events from this `GooglePlayServicesClient`.
abstract void | registerConnectionFailedListener(GooglePlayServicesClient.OnConnectionFailedListener listener) Registers a listener to receive connection failed events from this `GooglePlayServicesClient`.
abstract void | unregisterConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks listener) Removes a connection listener from this `GooglePlayServicesClient`.
abstract void | unregisterConnectionFailedListener(GooglePlayServicesClient.OnConnectionFailedListener listener) Removes a connection failed listener from the `GooglePlayServicesClient`.

## Public Constructors

#### public WalletClient (Activity activity, int environment, String accountName, GooglePlayServicesClient.ConnectionCallbacks connectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener)

Creates a Google Wallet client to connect to Google Play services.

##### Parameters

activity | The Activity to use for the connection.
environment | The Google Wallet environment to use. Specify `ENVIRONMENT_SANDBOX` until you have applied for and been granted access to the Production environment.
accountName | Google Account to use for this transaction. `null` lets the Wallet SDK choose a default account.
connectionCallbacks | The listener where the results of the asynchronous `connect()` call are delivered.
connectionFailedListener | The listener which will be notified if the connection attempt fails.

#### public WalletClient (Activity activity, int environment, String accountName, int theme, GooglePlayServicesClient.ConnectionCallbacks connectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener)

Creates a Google Wallet client to connect to Google Play services.

##### Parameters

activity | The Activity to use for the connection.
environment | The Google Wallet environment to use. Specify `ENVIRONMENT_SANDBOX` until you have applied for and been granted access to the Production environment.
accountName | Google Account to use for this transaction. `null` lets the Wallet SDK choose a default account.
theme | specify a theme to use for Wallet running on Android OS with `SDK_INT` >= `HONEYCOMB`. The only legitimate values are `THEME_HOLO_DARK` and `THEME_HOLO_LIGHT` as those are the only supported themes. User-created themes are not supported. Value ignored for Android OS with `SDK_INT` < `HONEYCOMB`.
connectionCallbacks | The listener where the results of the asynchronous `connect()` call are delivered.
connectionFailedListener | The listener which will be notified if the connection attempt fails.

## Public Methods

#### public void changeMaskedWallet (String googleTransactionId, String merchantTransactionId, int requestCode)

This method brings up a Google Wallet selector screen to allow your customer to select a new payment instrument or shipping address from their Google Wallet.

##### Parameters

googleTransactionId | Required field. Must be identical to the value returned in an earlier `MaskedWallet` in the same transaction.
merchantTransactionId | Optional merchant identifier for the transaction. The value will be echoed back in `MaskedWallet`, but is not otherwise used by the Wallet API. To omit, pass `null`
requestCode | will be passed back in onActivityResult where you can retrieve the result via `EXTRA_MASKED_WALLET`.

#### public void checkForPreAuthorization (int requestCode)

This API checks to see if a user has previously authorized the application to access their Wallet account.

##### Parameters

requestCode | will be passed back in onActivityResult where you can retrieve the result via `EXTRA_IS_USER_PREAUTHORIZED`.

#### public void connect ()

Connects the client to Google Play services. This method returns immediately, and connects to the service in the background. If the connection is successful, `onConnected(Bundle)` is called. On a failure, `onConnectionFailed(ConnectionResult)` is called.

#### public void disconnect ()

Closes the connection to Google Play services. No calls can be made on this object after calling this method.

#### public boolean isConnected ()

Checks if the client is currently connected to the service, so that requests to other methods will succeed. Applications should guard client actions caused by the user with a call to this method.

##### Returns

- true if the client is connected to the service.

#### public boolean isConnecting ()

Checks if the client is attempting to connect to the service.

##### Returns

- true if the client is attempting to connect to the service.

#### public boolean isConnectionCallbacksRegistered (GooglePlayServicesClient.ConnectionCallbacks listener)

Returns true if the specified listener is currently registered to receive connection events.

##### Parameters

listener | The listener to check for.

##### Returns

- true if the specified listener is currently registered to receive connection events.

#### public boolean isConnectionFailedListenerRegistered (GooglePlayServicesClient.OnConnectionFailedListener listener)

Returns true if the specified listener is currently registered to receive connection failed events.

##### Parameters

listener | The listener to check for.

##### Returns

- true if the specified listener is currently registered to receive connection failed events.

#### public void loadFullWallet (FullWalletRequest request, int requestCode)

Requests a `FullWallet`, which contains the payment credentials. You can retrieve the `FullWallet` in `onActivityResult` using the `requestCode` that you provide to this method. If there is a problem with the transaction then the Google Wallet selector will be shown and a `MaskedWallet` will be returned to reflect new selections by the user.

This function should only be called when the customer confirms the purchase.

Important: Because the credentials are in plain text it is important to transfer the payment credentials following PCI standards.

##### Parameters

requestCode | will be passed back in onActivityResult where you can retrieve the result via `EXTRA_FULL_WALLET` or `EXTRA_MASKED_WALLET` if the user had to make new selections.

#### public void loadMaskedWallet (MaskedWalletRequest request, int requestCode)

If an application has authorization, loadMaskedWallet() allows you to skip the Google Wallet selector and directly request the masked payment credentials. This provides a more seamless purchase experience for your customers. When you call this method, the Google Wallet selector will be shown only if necessary. Either way, you can retrieve the `MaskedWallet` in `onActivityResult` using the specified `requestCode`.

##### Parameters

requestCode | will be passed back in onActivityResult where you can retrieve the result via `EXTRA_MASKED_WALLET`.

#### public void notifyTransactionStatus (NotifyTransactionStatusRequest request)

Sends a notification to Google on whether the transaction succeeded or failed. This should always be called after payment processing as well as any failed validation checks.

#### public void registerConnectionCallbacks (GooglePlayServicesClient.ConnectionCallbacks listener)

Registers a listener to receive connection events from this `GooglePlayServicesClient`. If the service is already connected, the listener's `onConnected(Bundle)` method will be called immediately. Applications should balance calls to this method with calls to `unregisterConnectionCallbacks(ConnectionCallbacks)` to avoid leaking resources.

If the specified listener is already registered to receive connection events, this method will not add a duplicate entry for the same listener, but will still call the listener's `onConnected(Bundle)` method if currently connected.

Note that the order of messages received here may not be stable, so clients should not rely on the order that multiple listeners receive events in.

##### Parameters

listener | the listener where the results of the asynchronous `connect()` call are delivered.

#### public void registerConnectionFailedListener (GooglePlayServicesClient.OnConnectionFailedListener listener)

Registers a listener to receive connection failed events from this `GooglePlayServicesClient`. Unlike `registerConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks)`, if the service is not already connected, the listener's `onConnectionFailed(ConnectionResult)` method will not be called immediately. Applications should balance calls to this method with calls to `unregisterConnectionFailedListener(OnConnectionFailedListener)` to avoid leaking resources.

If the specified listener is already registered to receive connection failed events, this method will not add a duplicate entry for the same listener.

Note that the order of messages received here may not be stable, so clients should not rely on the order that multiple listeners receive events in.

##### Parameters

listener | the listener where the results of the asynchronous `connect()` call are delivered.

#### public void unregisterConnectionCallbacks (GooglePlayServicesClient.ConnectionCallbacks listener)

Removes a connection listener from this `GooglePlayServicesClient`. Note that removing a listener does not generate any callbacks.

If the specified listener is not currently registered to receive connection events, this method will have no effect.

##### Parameters

listener | the listener to unregister.

#### public void unregisterConnectionFailedListener (GooglePlayServicesClient.OnConnectionFailedListener listener)

Removes a connection failed listener from the `GooglePlayServicesClient`. Note that removing a listener does not generate any callbacks.

If the specified listener is not currently registered to receive connection failed events, this method will have no effect.

##### Parameters

listener | the listener to unregister.