Integrate the Google Wallet API: classes, objects and JWT
On Android, a pass is not a file: it is an object hosted by Google, attached to a class. Your server creates them through the Google Wallet API, then gives the customer an "Add to Google Wallet" link. This guide covers what that involves, and what eldo wallet does for you.
Classes and objects
| Concept | Role | Example |
|---|---|---|
| Class | The shared template: program, logo, colors, texts | Your brand's loyalty program |
| Object | One holder's copy: their ID, balance and barcode | Marie's card, 320 points |
Each pass type has its pair: LoyaltyClass / LoyaltyObject for loyalty, OfferClass / OfferObject for coupons, EventTicketClass for tickets, TransitClass and FlightClass for travel, GenericClass for the rest. IDs take the form ISSUER_ID.suffix.
Doing it yourself: the steps
- Create an issuer account in the Google Pay & Wallet Console and note the issuer ID.
- Create a Google Cloud project, enable the Google Wallet API and create a service account with its key.
- Authorize that service account in the issuer console.
- Create the class (for example a
LoyaltyClass) through the REST API. - Create one object per holder, attached to the class.
- Generate the add link: a JWT signed with the service account key, appended to
https://pay.google.com/gp/v/save/. - Request production access: until Google approves it, only test accounts can add your passes.
Keeping passes up to date
- To change a balance or a time, update the object: Google pushes the new version to the phone.
- To notify the holder, add a message to the object or the class.
- To change the design, update the class: every object follows.
And all of that for Android only: the iPhone needs a signed .pkpass file, see Generate a pkpass file.
With eldo wallet
eldo wallet publishes the Google Wallet classes and objects, signs the links and relays every update, together with the Apple Wallet version. Everything goes through the eldo wallet issuer account: no Google Wallet account to open (large accounts can use their own). See Apple Wallet vs Google Wallet.
| Doing it yourself | With the eldo wallet API |
|---|---|
| Open a Google Wallet issuer account and a service account | Not needed: eldo wallet issues with its own account |
Create the LoyaltyClass | Set up the card once: PATCH/store-cards |
Create one LoyaltyObject per holder | Create the customer: POST/clients |
| Sign a JWT for each add link | One link (shortLink) for Google Wallet and Apple Wallet |
| Update the object, add a message | PATCH/clients/{id}/gain, POST/push-notifications |
Create an OfferClass for coupons | POST/coupons |
To get started: the quickstart creates a loyalty card and sends it to a customer in three calls.
Learn more
- Apple Wallet and Google Wallet pass types
- Push notifications
- Google Wallet's Expressive Passes
- Corsica Ferries case study: 1.8 million tickets in Google Wallet