Get access to Android SDK

The Google Pay API for Passes for Android lets users save loyalty cards, gift cards, and offers to Google Pay with the click of a button. This tutorial guides you through integrating Save to Google functionality into your Android app.

The API is provided as part of Google Play Services, which provides core functionality for Android apps. For the purposes of this tutorial, we assume that you're familiar with the basic concepts and skills of application development for the Android platform. If you need to learn about Android development before getting started, work through some lessons in the Training for Android Developers.

To get started with this tutorial, whitelist your project, and set up Google Play Services.

Obtain credentials to whitelist your app

To successfully use the Google Pay API for Passes for Android in your native app, you'll need to whitelist the app. This is done using the SHA1 fingerprint in your developer's key and the package name.

To whitelist your application, you need to get the certificate's SHA1 fingerprint, by switching to a terminal window and running the Keytool utility:

keytool -exportcert -alias androiddebugkey -keystore path_to_debug_or_production_keystore -list -v

For the debug keystore, the password is android.

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

$ keytool -exportcert -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 example above. The fingerprint as well as the package name of the app are needed to whitelist the app. The app can be whitelisted by reaching out to your technical Google contact here with this information.

Set up Google Play Services

To import the Google Play Services library, follow the instructions to Set Up Google Play Services. If you don't already have it, you'll need to get the Android SDK. Use Google Play Services version 15 or above.

Tie the Android API to your Google Pay API for Passes Account

Your Google Pay API for Passes account should have been created for you by your Google point of contact. The Google Pay API for Passes Merchant Center is a website that you can use to manage your account and all of your associated classes and objects. To allow the Android API to access your account, share the account with the email sugar-s2w-prod@system.gserviceaccount.com, as shown in the following image:

Once you've completed this setup process, try saving to Google Pay with either of the following use cases:

Both methods show how customers can easily save loyalty cards, gift cards, and offers from your app to Google Pay.

Envoyer des commentaires concernant…

Google Pay for Passes