With the Google Wallet API (REST), do we have to create a new eventTicketClass for each new event?

356 views Asked by At

I want to use Google Wallet API (REST) ​​to generate tickets for events. There are object classes (eg: EventTicketClass, GenericClass) and objects for the tickets themself.

I created a GenericClass in the Google Pay & Wallet Console and I am able to call it with my code and generate an object and define all the text I want on the ticket. I can create multiple objects with this specific same class, for different events, and define the text on each object without creating a new class.

But it is suggested to use eventTicketClass for event tickets. So I also created an EventTicketClass. When creating it in Google Pay & Wallet Console, I need to set an event name. The field is required. I am also able to generate an object with this class with the API and everything works fine, but I am unable to change the event name when generating the object. It's like I can't overwrite the value of the eventName inherited from the class.

Knowing that in my application, I would have several different events on different dates (eg: Show X, Movie Y, Sports Event Z), my question is the following:

By design, do I absolutely have to create a new class EventTicketClass for each new event and define the name of the event, its location and its date in the class, and then create the objects linked to this class?

  • I asked ChatGPT 4 the question and he insisted that we can reuse the same eventTicketClass for different events.
  • I searched the documentation and Google for an answer to this question, but couldn't find a clear answer.
  • I looked at the source code of different examples on the web and they create a new class each time.
  • I tried several ways to pass the eventName in the JSON code hoping to overwrite the eventName of the object that is inherited from the class, without success.

I found this article : https://developers.google.com/wallet/retail/offers/overview/add-to-google-wallet-flow?hl=en

We can read this :

A Passes Class defines a set of properties that are common across multiple passes, similar to a template. For example, if you were issuing tickets of an event, the Passes Class would define fields that are the same across all tickets, such as the event name, date, and time.

My understanding is that the event name and date are defined only in the class, not in the object. Which would explain why it is not technically possible to overwrite the event name directly in the object. It even makes sense that this is managed only at the class level.

I would still like to have confirmation from the community.

1

There are 1 answers

0
grundyoso On

You do need to create a new class per event, but we’ve abstracted that away - you can create a single template and we’ll handle class and object management for you at passninja.com