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 you have completed your Business profile, navigate to Google Wallet API page and click on Request access. Indicate in the description that you will use Android SDK, complete the checklist and finally submit the request.

While waiting for your Passes access to be granted, create a temporary developer account or 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

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 reaching out to the support team through the Business Console contact support widget.

4. 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:16.0.1'
}

5. 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. Click on Create a class
  3. Choose Generic
  4. Fill up all mandatory fields marked with *
  5. 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.