Page Summary
-
Google Wallet Passes are created using two components: a Passes Class (template) and a Passes Object (instance with data).
-
You can create Passes Classes through the Google Wallet Business Console, REST API, or Android SDK, providing flexible options for development.
-
Passes Objects require a
classIdand uniqueid, and are defined using JSON, mirroring the structure of Passes Classes. -
Various predefined pass types are available, including a "Generic" type for custom implementations.
-
Passes can incorporate features like Smart Tap, Enrollment, and Sign In to enhance user engagement.
Almost all of the passes you can issue for an end-user to save in their Google Wallet are defined by two components: a Passes Class and a Passes Object. Anytime you issue a pass to a user, you will need an instance of both a Passes Class and a Passes Object, which tells the Google Wallet API what type of pass to construct, as well as details to display on the pass, such as the value of a gift card or a ticketholder's name.
The Google Wallet API provides a predefined set of Passes Classes and Passes Objects that you create instances of, then use to create a pass that is issued to a user, such as GiftCardClass and GiftCardObject, GenericClass and GenericObject, and others.
Each Passes Class and Passes Object instance is defined as a JSON object, which has a set of required and optional properties that correspond to the specific use case intended for that pass type.
Create a Passes Class
A Passes Class can be thought of as a shared template that passes are created from. A Passes Class defines certain properties that will be included in all passes that use it. A Pass Issuer can create multiple classes, each with their own distinctive set of properties that define attributes like style and appearance, as well as additional features like Smart Tap, and the Enrollment and Sign In.
Passes Classes may be created using the Google Wallet REST API, Google Wallet Android SDK, or in the Google Wallet Business Console.
For new users, the Business Console is the easiest way to get started with creating a Passes Class, as it provides a simple user interface, where you can define the various fields of your first Passes Class by filling out form fields.
For advanced users, creating Passes Classes programmatically is the best approach.
Use the Google Wallet Business Console
To create a Passes Class in the Google Wallet Business console, do the following:
- Go to the Google Pay and Wallet Business Console and sign in with your Google Wallet API Issuer Account.
- On the "Google Wallet API" card, click the "Manage passes" button.
- Under 'Get publishing access', click the 'Create a class' button.
- Choose a pass type from the dialog. Google Wallet offers various pass types (Event Ticket, Offer, Loyalty Card, etc.). For a flexible use case, select "Generic" as your pass type.
- Fill in the appropriate values for the required fields.
- Click the 'Create class' button to save your class.
Use the Google Wallet REST API
To create a Passes Class using the Google Wallet REST API, send a POST request to https://walletobjects.googleapis.com/walletobjects/v1/eventTicketClass. For more information, see the reference documentation.
Java
To start your integration in Java, refer to our complete code samples on GitHub.
/** * Create a class. * * @param issuerId The issuer ID being used for this request. * @param classSuffix Developer-defined unique ID for this pass class. * @return The pass class ID: "{issuerId}.{classSuffix}" */ public String createClass(String issuerId, String classSuffix) throws IOException { // Check if the class exists try { service.eventticketclass().get(String.format("%s.%s", issuerId, classSuffix)).execute(); System.out.printf("Class %s.%s already exists!%n", issuerId, classSuffix); return String.format("%s.%s", issuerId, classSuffix); } catch (GoogleJsonResponseException ex) { if (ex.getStatusCode() != 404) { // Something else went wrong... ex.printStackTrace(); return String.format("%s.%s", issuerId, classSuffix); } } // See link below for more information on required properties // https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass EventTicketClass newClass = new EventTicketClass() .setEventId(String.format("%s.%s", issuerId, classSuffix)) .setEventName( new LocalizedString() .setDefaultValue( new TranslatedString().setLanguage("en-US").setValue("Event name"))) .setId(String.format("%s.%s", issuerId, classSuffix)) .setIssuerName("Issuer name") .setReviewStatus("UNDER_REVIEW"); EventTicketClass response = service.eventticketclass().insert(newClass).execute(); System.out.println("Class insert response"); System.out.println(response.toPrettyString()); return response.getId(); }
PHP
To start your integration in PHP, refer to our complete code samples on GitHub.
/** * Create a class. * * @param string $issuerId The issuer ID being used for this request. * @param string $classSuffix Developer-defined unique ID for this pass class. * * @return string The pass class ID: "{$issuerId}.{$classSuffix}" */