public final class

Wallet

extends Object
java.lang.Object
   ↳ com.google.android.gms.wallet.Wallet

Class Overview

The main entry point for Google Wallet integration. You need to build a GoogleApiClient using the API and the appropriate Wallet.WalletOptions. Once you have called connect() and your listener has received the onConnected(android.os.Bundle) callback, then you can call the various Wallet methods.

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

You should instantiate an instance of GoogleApiClient 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 or simply do not set it using setAccountName(String). 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, set the account using setAccountName(String). To change the account, construct a new GoogleApiClient 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 using setEnvironment(int). For production access, you must specify ENVIRONMENT_PRODUCTION.

Summary

Nested Classes
class Wallet.WalletOptions Options for using the Wallet API. 
Fields
public static final Api API Add this to your GoogleApiClient via addApi(com.google.android.gms.common.api.Api, com.google.android.gms.common.api.GoogleApiClient.ApiOptions).
Public Methods
static void changeMaskedWallet(GoogleApiClient googleApiClient, 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.
static void checkForPreAuthorization(GoogleApiClient googleApiClient, int requestCode)
This API checks to see if a user has previously authorized the application to access their Wallet account.
static void loadFullWallet(GoogleApiClient googleApiClient, FullWalletRequest request, int requestCode)
Requests a FullWallet, which contains the payment credentials.
static void loadMaskedWallet(GoogleApiClient googleApiClient, 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.
static void notifyTransactionStatus(GoogleApiClient googleApiClient, NotifyTransactionStatusRequest request)
Sends a notification to Google on whether the transaction succeeded or failed.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

Public Methods

public static void changeMaskedWallet (GoogleApiClient googleApiClient, 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
googleApiClient An instance of GoogleApiClient configured to use the Wallet API
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 static void checkForPreAuthorization (GoogleApiClient googleApiClient, int requestCode)

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

Parameters
googleApiClient An instance of GoogleApiClient configured to use the Wallet API
requestCode will be passed back in onActivityResult where you can retrieve the result via EXTRA_IS_USER_PREAUTHORIZED.

public static void loadFullWallet (GoogleApiClient googleApiClient, 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
googleApiClient An instance of GoogleApiClient configured to use the Wallet API
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 static void loadMaskedWallet (GoogleApiClient googleApiClient, 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
googleApiClient An instance of GoogleApiClient configured to use the Wallet API
requestCode will be passed back in onActivityResult where you can retrieve the result via EXTRA_MASKED_WALLET.

public static void notifyTransactionStatus (GoogleApiClient googleApiClient, 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.

Parameters
googleApiClient An instance of GoogleApiClient configured to use the Wallet API