Use cases

This guide outlines specific ways that you can use the Google Pay API for Passes to engage with your customers for the transit pass vertical. The API allows you to offer your customers the following options:

Update passes

If there are changes to a pass after it's created, use the REST API to deliver those changes to users. If the changes affect only classes, you can also use the Google Pay Merchant Center. Pass updates are an important way to engage with your users.

To update the way passes are displayed, such as when the logo changes, you only need to update or patch the TransitClass or use the Google Pay Merchant Center. Google propagates this information to all TransitObjects associated to the updated TransitClass. This is the case for all fields defined at the TransitClass level.

To update a single pass, such as when the departure time changes, you need to update or patch a single TransitObject. This is the case for all fields defined at the TransitObject level.

Sometimes, you might not know when a change happens, or when to trigger an update or patch request. In cases like that, periodically schedule update or patch requests for each and every class and object. You can find all classes of a particular issuer account if you call the TransitClass list method. You can find all objects of a particular class if you call the TransitObject list method.

Define journeys with multiple legs

Often, one journey includes multiple legs rather than a direct trip to a person's destination. In order to fulfill this journey, transit operators may issue one pass for each leg of the journey or a single pass. The Google Pay API for Passes mimics this behavior, with either one TransitObject per leg or a single multi-leg TransitObject.

It's very simple to use one TransitObject per leg. You can use object.ticketLeg to define the leg. You can create and update each pass as if they were independent. However, you might want to define a way to group these passes together. For more details, see Group multiple transit passes. This is the preferred way to define journeys with multiple legs.

Multi-leg TransitObject objects should be used only if this type of aggregated pass is accepted in each leg and only if the information on the pass, for example the QR code, is the same for all the legs. You can use the object.ticketLegs[] list to define the legs. The card portion of the pass only shows the first leg origin and the last leg destination, while a full itinerary is displayed in the details section of the pass.

Make a button to save multiple passes

If a user buys multiple passes, and they're likely to save all of them to Google Pay, then it's useful to allow a user to save many objects with one click of a Save to Google Pay button or link. You can define multiple objects or classes when you sign the JSON Web Token (JWT).

You must create the JWT in either of the following formats:

  • With pre-inserted classes and objects only.
  • With only object and class resources that are fully defined within the JWT.

For more information on the UI representation of Passes, see Group multiple transit passes.

Group multiple transit passes

There are features which work differently if they're used on a group rather than individual objects, such as status notifications, or the organization of multiple saved Passes in the user interface.

TransitObject objects are only considered to be a group if they share the same object.classId, object.ticketLeg.departureDateTime, and one of the following properties listed by priority:

  1. object.tripId
  2. object.purchaseDetails.confirmationCode

This is meant to group passes for the same journey but for different passengers.

If you wish for passes to be grouped, we recommend you consistently set these fields, even if a particular TransitObject isn't grouped with any other.

Upcoming journey notification

Google Pay sends a notification to the user one hour prior to the journey. The journey time is defined by object.ticketLeg.departureDateTime or the first object.ticketLegs[].departureDateTime.

To receive this notification, the user must have notifications enabled. To check this, they can navigate to Settings > Notifications and see if Updates about your passes is turned on.

The notification shows up in the notifications area, and in the lock screen, if the user has notifications enabled for the lock screen

The notification has the following unmodifiable format:

Ticket fot your upcoming trip to object.ticketLeg.destinationName
Expand for more options

If they tap the notification and unlock their device, their pass appears in the Google Pay app.

If the user has multiple passes, only the soonest useable pass is shown. If they've saved grouped passes as per Group multiple transit passes, the notification only shows one of the passes in the group. However, when they tap it, the user can swipe left and right to see the other passes in that group.

The notification is pinned and won't auto-dismiss after a user opens it. Auto-dismiss occurs 60 minutes after object.ticketLeg.departureDateTime or the first object.ticketLegs[].departureDateTime.

Handle expired passes

Under the "Passes" tab of the Google Pay app, there's an "Expired passes" section that contains all archived or inactive passes. A pass is moved to the "Expired passes" section if at least one of the following conditions is true:

  • It's been at least 24 hours since object.ticketLeg.arrivalDateTime or the last object.ticketLegs[].arrivalDateTime expired. The pass moves to "Expired passes" anytime between 24-48 hours after object.ticketLeg.arrivalDateTime or the last object.ticketLegs[].arrivalDateTime expires.
  • object.validTimeInterval.end.date expires. The pass moves to "Expired passes" anytime up to 24 hours after object.validTimeInterval.end.date expired.
  • The object.state field is marked as Expired, Inactive, or Completed.

Once a user has a pass saved, reference its objectId in order to link to the pass.

Use the following link to reference the pass:

https://pay.google.com/gp/v/object/{<issuerId>}.{<ObjectId>}

The pass can be viewed with the Google Pay app or a web browser.