Typical API flow

The following diagram illustrates a typical communication flow used to insert a class, save an object, and update an object. All actions between your server, the web browser, and Google Pay API for Passes are your responsibility to implement. The following diagram uses Loyalty as an example, but all other Passes could use a similar flow.

Typical API flow for JS buttons and JWT web links

The following outline, and the prior diagram, detail the typical API flow for JavaScript (JS) buttons and JSON Web Tokens (JWTs):

  1. Loyalty card issuer creates a LoyaltyClass.
    1. Your server defines the LoyaltyClass.
    2. Your server makes a POST request to insert theLoyaltyClass in the Google Pay API for Passes server.
  2. Your server has a service to generate a JWT for a LoyaltyObject for a particular LoyaltyClass. This object represents that user's loyalty card.
    1. Your server uses a JWT to render a Save to Google Pay (S2GP) button:
      • For websites, use our JavaScript button.
      • For email, SMS, and native apps, use the JWT link with a S2GP button.
  3. The user clicks or taps Save to Google Pay on the loyalty card issuer's website, email, native app, or SMS.
    1. The user is taken to a landing page to save a LoyaltyClass object. The object to be saved is rendered on the landing page based on the JWT. If the button is tapped from a native app, the user is prompted to save the object in the Google Pay app.
    2. The user clicks Save to Google Pay on the issuer's property to save the LoyaltyObject.
    3. The LoyaltyObject is inserted to the Google server, then pushed to the Google Pay app. The LoyaltyObject is referred to as a "Loyalty Pass."
  4. Card issuer updates card data:
    1. The loyalty card issuer does a GET request of the LoyaltyObject with the use of the Object.id.
    2. The loyalty card issuer updates the LoyaltyObject.
    3. The loyalty card issuer makes a PUT or PATCH request to insert the updated LoyaltyObject on the Google Pay API for Passes server.
    4. The LoyaltyObject is pushed to the Google Pay app.

"Skinny" JWT variation

Due to truncation by browsers, JWTs used in web links must not exceed 1800 characters. If this becomes a challenge, it might be best for you to insert both the class and object beforehand. Then, the JWT only needs to contain the object id field.

The following diagram shows an API flow to Add the Save to Google Pay button to your email or SMS.

Visszajelzés küldése a következővel kapcsolatban: