How classes and objects work

Stay organized with collections Save and categorize content based on your preferences.

This page describes the relationship between classes and objects, which is fundamental to how the Google Wallet API works. This page also covers how objects link to users.

Classes and objects

The Google Wallet API uses the concept of an object to digitally represent a single user's physical offers. 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 Google Wallet a user has in their Google Wallet app is represented by one OfferObject, which references a OfferClass.

To make it easier to implement changes that need to apply to all offers, every object references a class.

A class contains common data across objects. For example, OfferClass stores the redemptionChannel, while OfferObject stores an individual's barcode. The class and object relationship might be one-to-one, but a class can be referenced by many objects.

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

Objects and linking

The Google Wallet API uses the concept of an Object to represent offer. For example, an OfferObject represents each offer a user has in their Google Wallet app.

After a user clicks the Add to Google Wallet button to add offer, the API inserts an Object that establishes a link between the object and the user. This means that when the user clicks the button again, a link already exists to Object.

If a user removes their Pass from the Google Wallet app, the link to the corresponding Object is de-linked. This means that a user can click the Add to Google Wallet button again, to re-establish that link without a new Object.

When you develop your Pass, we recommend that you use a new Object id between adds because the API doesn't re-insert an Object that matches an id.

Remember, when you remove a Pass from your account, you don't lose your Object. The Object is only de-linked from your account, and you can link to it again.