Add a flight journey with multiple legs

Stay organized with collections Save and categorize content based on your preferences.

Often, one flight journey includes multiple legs rather than a direct journey to a person's destination. During this journey, airlines issue one boarding pass per leg of the journey. The Google Wallet API mimics this behavior, with one FlightObject per leg.

This means if you have two passengers who fly from SFO to LAX to TPE, there would be two FlightClass structures and four FlightObject objects:

  FlightClass A (SFO to LAX: Carrier, flight number, departure time) FlightClass B (LAX to TPE: Carrier, flight number, departure time)
Passenger Q FlightObject: id_01 FlightObject: id_02
Passenger Z FlightObject: id_03 FlightObject: id_04

These fields reflect the physical boarding passes. Both Passenger Q and Passenger Z would have two paper boarding passes.

If a user buys multiple passes, and they're likely to add all of them to Google Wallet, then it's useful to allow a user to add many objects with one click of a Add to Google Wallet 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.

You can save multiple passengers for the same flight leg, or multiple passengers for multi-flight legs, with one Add to Google Wallet button or link.

In the JSON Web Token (JWT) to be signed, include multiple Passes in the array. The following examples show two variations on how to do this:

  1. This example saves objects of the same pass with one JWT. It uses pre-inserted flight classes and objects, and it only sends the IDs of each object. Note that the classId property is optional. It's shown here for demonstrative purposes.

    {
       "aud": "google",
       "origins": [],
       "iss": "your_iam_account@appspot.gserviceaccount.com",
       "iat": 1534891254,
       "typ": "savetowallet",
       "payload": {
           "flightObjects": [
               {
                   "classId": "<my_issuer_id>.FlightClass_A",
                   "id": "<my_issuer_id>.FlightObject_A_01"
               },
               {
                   "classId": "<my_issuer_id>.FlightClass_A",
                   "id": "<my_issuer_id>.FlightObject_A_02"
               }
           ]
       }
    }
  2. This example defines a class, as well as multiple objects that reference this class. Both the class and the objects are inserted when the user adds the passes.

    {
        "aud": "google",
        "origins": [
            "http://localhost:8080"
        ],
        "iss": "s2googlepay-api@sunlit-pixel-197421.google.com.iam.gserviceaccount.com",
        "iat": 1536886148,
        "typ": "savetoandroidpay",
        "payload": {
            "flightObjects": [
                {
                    "classId": "<my_issuer_id>.FlightClass_A",
                    "state": "active",
                    "passengerName": "test name adHoc",
                    "id": "<my_issuer_id>.FlightObject_A",
                    "reservationInfo": {
                        "confirmationCode": "testcode"
                    }
                },
                {
                    "classId": "<my_issuer_id>.FlightClass_A",
                    "state": "active",
                    "passengerName": "test name",
                    "id": "<my_issuer_id>.flight_multi_0913-obj01-copy",
                    "reservationInfo": {
                        "confirmationCode": "testcode"
                    }
                }
            ],
            "flightClasses": [
                {
                    "origin": {
                        "terminal": "2",
                        "gate": "A1",
                        "kind": "walletobjects#airportInfo",
                        "airportIataCode": "SFO"
                    },
                    "kind": "walletobjects#flightClass",
                    "reviewStatus": "underReview",
                    "destination": {
                        "terminal": "1",
                        "gate": "B3",
                        "kind": "walletobjects#airportInfo",
                        "airportIataCode": "TPE"
                    },
                    "id": "<my_issuer_id>.FlightClass_A",
                    "flightHeader": {
                        "carrier": {
                            "carrierIataCode": "BR"
                        },
                        "flightNumber": "123"
                    },
                    "localScheduledDepartureDateTime": "2027-03-05T06:30:00",
                    "issuerName": "Baconrista Airlines"
                }
            ]
        }
    }
    

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