Use cases

This guide outlines the following specific ways that you can use the Google Pay API for Passes to engage with your customers for the Loyalty vertical:

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 LoyaltyClass or use the Google Pay Merchant Center. Google propagates this information to all LoyaltyObjects associated to the updated LoyaltyClass. This is the case for all fields defined at the LoyaltyClass level.

To update a single pass, such as when the loyalty card points balance changes, you need to update or patch a single LoyaltyObject. This is the case for all fields defined at the LoyaltyObject 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 LoyaltyClass list method. You can find all objects of a particular class if you call the LoyaltyObject list method.

Scan in the Google Pay app

Users can add some loyalty card to their Google Pay app when they either scan or manually add the loyalty card details. The Google Pay API for Passes creates a LoyaltyObject that doesn't reference a LoyaltyClass you've previously defined. No action is required on your part to create the new object or class. However, the LoyaltyObject created by the Google Pay API for Passes can't be updated and behaves like a static pass.

Linked offers

Linked offers allow existing offers to appear within the loyalty card view, making relevant content easier for the user to discover. The writable list field linkedOfferIds in a LoyaltyObject indicates which offers are associated with the loyalty card.

Creating the offer before linking

To link a linked offer, the offer classes and objects linked to the loyalty card must already be created. To learn more about creating offers, see Offers. Unlike standalone offers, linked offers do not require a user to explicitly save the offer. The id field found in the OfferObject is used to point to the LoyaltyObject.

Link offers to a loyalty card

The existing offers can be linked to a loyalty card using the REST API calls insert, or update, or patch, or modifyLinkedOfferObjects.

When offers are linked to a loyalty card upon creation of the loyalty card using the insert call or when offers are both linked and unlinked to an existing loyalty card using the update call, the field linkedOfferIds can be written with the rest of the LoyaltyObject using the established format:

{
  "id": "2945482443380251551.ExampleObject1",
  "classId": "2945482443380251551.ExampleClass1",
  ...
  "linkedOfferIds": [
    "2945482443380251551.OfferObject1",
    "2945482443380251551.OfferObject2"
  ]
}

When offers are linked and unlinked to an existing loyalty card using the patch call, the field linkedOfferIds can be the only field in the request:

{
  "linkedOfferIds": [
    "2945482443380251551.OfferObject1",
    "2945482443380251551.OfferObject2"
  ]
}

However, in order to avoid mistakes whe dealing with arrays, specify which linked offers need to be added and which need to be removed, and be able to omit the linked offers that should remain untouched, we recommend to use the modifyLinkedOfferObjects method as in the following example:

{
  "linkedOfferObjectIds" {
    "addLinkedOfferObjectIds": [
      "2945482443380251551.OfferObject1",
      "2945482443380251551.OfferObject2"
    ],
    "removeLinkedOfferObjectIds": [
      "2945482443380251551.OfferObject3",
      "2945482443380251551.OfferObject4"
    ]
  }
}

Designing loyalty card with linked offers

Linked offers will appear in a loyalty card view between the card section and the details section, as shown below. Only a maximum of 5 linked offers are displayed in the carousel. If more offers are linked to the loyalty card, the user can click on the "More" button at the end of the carousel to display them all.

Linked offers

When clicked the linked offer uses a simplified offer design, as shown below.

Linked offer clicked

Geofenced notifications

Google can trigger notifications related to a consumer's saved Object based on the consumer's proximity to a location you've defined.

There are two ways geolocation information is added:

  1. Geolocation information from Google Maps is used when a Google Pay API for Passes Merchant Center account is created.
  2. Coordinates can be added to the object or class through the REST API.

For instructions on adding coordinates to objects or classes, see Add geolocation information using the REST API.

Geofencing concepts

Using geolocation information in Google Maps, Google algorithmically determines if the user is physically in the store or area. This detection applies to all classes and objects developed under the Google Pay API for Passes Merchant Center account.

The algorithm considers GPS, Wifi, Bluetooth, movement, dwell time and other factors. When the user is determined to be physically present, a geofenced notification is triggered.

If coordinates are manually specified in the Object, the geofenced notification is triggered when they are 150 meters from the coordinates.

Frequency, throttling, and user opt-out of geofenced notifications

At maximum, a user receives up to four notifications per day.

When there are multiple saved objects within the geofence, a single (per Google Pay API for Passes Merchant Center account), unmodifiable notification with a carousel appears. Objects are cyclable within the carousel:

For geofenced notifications to work, the user must enable Updates about your items in the Google Pay app’s notification settings and must have location services turned on for their device.

Add geolocation information using the REST API

You can specify an array of locations (latitudes and longitudes) in your classes or objects. Google checks the user's current geolocation against the list of locations associated with a class or object and notifies the user if they are within 150 meters of one of the locations. The following are code samples showing how to specify locations in your classes or objects:

Resource

{
  ... //Class or Object content

  "locations": [{
    "kind": "walletobjects#latLongPoint",
    "latitude": 37.422087,
    "longitude": -161446
  }, {
    "kind": "walletobjects#latLongPoint",
    "latitude": 37.429379,
    "longitude": -121.12272999999999
  }, {
    "kind": "walletobjects#latLongPoint",
    "latitude": 37.333646,
    "longitude": -122.884853
  }]
}

Java

List<LatLongPoint> locations = new ArrayList<LatLongPoint>();
locations.add(new LatLongPoint().setLatitude(37.422087).setLongitude(
    -122.161446));
locations.add(new LatLongPoint().setLatitude(37.429379).setLongitude(
    -121.12272999999999));
locations.add(new LatLongPoint().setLatitude(37.333646).setLongitude(
    -122.884853));

yourClassOrObject.setLocations(locations);

PHP

$locations = array(
  array(
    'kind' => 'walletobjects#latLongPoint',
    'latitude' => 37.442087,
    'longitude' => -122.161446
  ),
  array(
    'kind' => 'walletobjects#latLongPoint',
    'latitude' => 37.429379,
    'longitude' => -122.12272999999999
  ),
  array(
    'kind' => 'walletobjects#latLongPoint',
    'latitude' => 37.333646,
    'longitude' => -121.884853
  )
);

Python

offer_class_object = {
  # class or object content
  'locations': [{
    'kind': 'walletobjects#latLongPoint',
    'latitude': 37.442087,
    'longitude': -122.161446
    },{
    'kind': 'walletobjects#latLongPoint',
    'latitude': 37.429379,
    'longitude': -122.12272999999999
    },{
    'kind': 'walletobjects#latLongPoint',
    'latitude': 37.333646,
    'longitude': -121.884853
  }]
}

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:

  • 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.