Prerequisites

Before you can start integrating with the Google Wallet API, complete the following steps:

1. Sign up for a Google Wallet API Issuer account

An Issuer account is required to create and distribute passes for Google Wallet. Get your issuer account by signing up for Google Pay and Wallet Console. After signing up, navigate to Google Wallet API page and click on Build your first pass. Once you accept the terms of service you can start creating a pass class.

After the above step you can also try out the Codelab.

2. Get familiar with application development on Android platform

For the purposes of this tutorial, get familiar with the basic concepts and skills of application development for the Android platform. If you need to learn about Android development before you get started, work through some lessons in the Training for Android Developers.

3. Obtain credentials to authorize your app

To successfully use the Google Wallet API for Android in your Android app, you need to authorize your app. You can do this with the SHA1 fingerprint in your developer's key and the package name.

To get approval for your application, you need to get the certificate's SHA1 fingerprint. To find the fingerprint, open a terminal window and run the Keytool utility:

keytool -alias androiddebugkey -keystore path_to_debug_or_production_keystore -list -v

The debug keystore is typically located at ~/.android/debug.keystore and its password is android.

The Keytool prints the fingerprint to the shell. For example:

$ keytool -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
Enter keystore password: Type "android" if using debug.keystore
Alias name: androiddebugkey
Creation date: Aug 27, 2012
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 503bd581
Valid from: Mon Aug 27 13:16:01 PDT 2012 until: Wed Aug 20 13:16:01 PDT 2042
Certificate fingerprints:
   MD5:  1B:2B:2D:37:E1:CE:06:8B:A0:F0:73:05:3C:A3:63:DD
   SHA1: D8:AA:43:97:59:EE:C5:95:26:6A:07:EE:1C:37:8E:F4:F0:C8:05:C8
   SHA256: F3:6F:98:51:9A:DF:C3:15:4E:48:4B:0F:91:E3:3C:6A:A0:97:DC:0A:3F:B2:D2:E1:FE:23:57:F5:EB:AC:13:30
   Signature algorithm name: SHA1withRSA
   Version: 3

4. Authorize your app in the Google Pay and Wallet Console

Copy the SHA1 fingerprint, which is highlighted in the preceding example. The fingerprint and the package name of the app are needed to authorize the app. The app can be authorized by completing the following steps:

  1. Navigate to the Google Pay and Wallet Console
  2. Select Google Wallet API on the left-hand menu
  3. Select the Additional features tab
  4. Scroll down to the App permissions section
  5. Click the Add an app button
  6. Input your package name and signature key fingerprint
  7. Click the Add application button
After completing these steps, your application package is now authorized and you can view your application package in the App permissions section.

5. Setup Google play services

If you don't already have Android Studio, download and install Android Studio.

The Google Wallet for Android is part of Google Play services. To import Google Play services libraries, follow the instructions to set up Google Play services.

In particular, to import the Google Wallet API for Android, add the following to the dependencies block to the build.gradle file in the app module:

dependencies {
  implementation 'com.google.android.gms:play-services-pay:16.0.3'
}

6. Create a Passes Class

Before you can create and add a Generic pass, you must first create a GenericClass. This can be done by signing in into the Google Pay and Wallet Console, navigating to the Google Wallet API page and creating a new GenericClass.

  1. Make sure you are on Manage tab
  2. You should see "You're in demo mode" if this is your first time ever creating a pass.
  3. While in demo mode, click on "Set up test accounts" to add test accounts. Only these accounts will be able to save the passes while your issuer account is in demo mode.
  4. Click on Create a class
  5. Choose Generic
  6. Fill up all mandatory fields marked with *
  7. Click on Create class

Repeat the steps above if you require multiple Generic passes.

Now that you have successfully created a GenericClass, you can proceed to Add passes to Google Wallet.