How it works

This page describes the relationship between classes and objects, which is fundamental to how Google Pay API for Passes works. This page also covers how objects are linked to users.

Classes and objects

The Google Pay API for Passes uses the concept of an object to digitally represent a single user's physical loyalty cards, gift cards, offers, event tickets, boarding passes for flights, and transit passes. The API uses the concept of a class to allow management of data common across all users. To cover specific use cases, each vertical has its own respective object and class.

For example, each loyalty card a user has in their Google Pay app is represented by one LoyaltyObject, which references a LoyaltyClass. Similarly, each gift card in a user’s Google Pay app is represented by one GiftCardObject, which references a GiftCardClass.

Each object references a class so that it's easier to make changes that should be applied to all loyalty cards, gift cards, offers, event tickets, boarding passes for flights, and transit passes.

A class contains common data across objects. For example, LoyaltyClass stores the programName, while LoyaltyObject stores an individual’s accountId. The class and object relationship can be one-to-one, but it isn't necessarily so. A class can be referenced by many objects.

Changes made to the class or object are propagated immediately. Users can see these changes on the Google Pay app when they sync.

Objects and linking

The Google Pay API for Passes uses the concept of an Object to represent loyalty cards, gift cards, offers, event tickets, boarding passes for flights, and transit passes. For example, each loyalty card a user has in their Google Pay app is represented by one LoyaltyObject.

When a user saves loyalty cards, gift cards, offers, event tickets, boarding passes for flights, and transit passes using the Save to Google Pay button, the API inserts an Object and then establishes a link between the object and the user. This means if the user clicks the button again, a new Object isn't inserted. A link already exists, so the Object isn't re-linked.

If a user removes their Pass from the Google Pay app, the Object they were linked to isn't removed. Instead, it's de-linked. If they were to click the Save to Google Pay button again, it would re-establish the link rather than creating a new Object.

While developing your Pass, a new Object id should be used between saves since the API doesn't re-insert an Object that matches an existing id.

Remember, removing a Pass from your account doesn't actually remove the Object. The Object is only de-linked from your account.

Envoyer des commentaires concernant…

Google Pay for Passes