Create Passes Classes and Passes Objects

Almost all of the passes you can issue for an end-user to save in their Google Wallet are defined by two components: a Passes Class and a Passes Object. Anytime you issue a pass to a user, you will need an instance of both a Passes Class and a Passes Object, which tells the Google Wallet API what type of pass to construct, as well as details to display on the pass, such as the value of a gift card or a ticketholder's name.

The Google Wallet API provides a predefined set of Passes Classes and Passes Objects that you create instances of, then use to create a pass that is issued to a user, such as GiftCardClass and GiftCardObject, GenericClass and GenericObject, and others.

Each Passes Class and Passes Object instance is defined as a JSON object, which has a set of required and optional properties that correspond to the specific use case intended for that pass type.

Create a Passes Class

A Passes Class can be thought of as a shared template that passes are created from. A Passes Class defines certain properties that will be included in all passes that use it. A Pass Issuer can create multiple classes, each with their own distinctive set of properties that define attributes like style and appearance, as well as additional features like Smart Tap, and the Enrollment and Sign In.

Passes Classes may be created using the Google Wallet REST API, Google Wallet Android SDK, or in the Google Wallet Business Console.

For new users, the Business Console is the easiest way to get started with creating a Passes Class, as it provides a simple user interface, where you can define the various fields of your first Passes Class by filling out form fields.

For advanced users, creating Passes Classes programmatically is the best approach.

Use the Google Wallet Business Console

To create a Passes Class in the Google Wallet Business console, do the following:

  1. Go to the Google Pay and Wallet Business Console and sign in with your Google Wallet API Issuer Account.
  2. On the "Google Wallet API" card, click the "Manage passes" button.
  3. Under 'Get publishing access', click the 'Create a class' button.
  4. Choose a pass type from the dialog. Google Wallet offers various pass types (Event Ticket, Offer, Loyalty Card, etc.). For a flexible use case, select "Generic" as your pass type.
  5. Fill in the appropriate values for the required fields.
  6. Click the 'Create class' button to save your class.

Use the Google Wallet REST API

To create a Passes Class using the Google Wallet REST API, send a POST request to https://walletobjects.googleapis.com/walletobjects/v1/giftCardClass. For more information, see the reference documentation.

Java

To start your integration in Java, refer to our complete code samples on GitHub.

/**
 * Create a class.
 *
 * @param issuerId The issuer ID being used for this request.
 * @param classSuffix Developer-defined unique ID for this pass class.
 * @return The pass class ID: "{issuerId}.{classSuffix}"
 */
public String createClass(String issuerId, String classSuffix) throws IOException {
  // Check if the class exists
  try {
    service.giftcardclass().get(String.format("%s.%s", issuerId, classSuffix)).execute();

    System.out.printf("Class %s.%s already exists!%n", issuerId, classSuffix);
    return String.format("%s.%s", issuerId, classSuffix);
  } catch (GoogleJsonResponseException ex) {
    if (ex.getStatusCode() != 404) {
      // Something else went wrong...
      ex.printStackTrace();
      return String.format("%s.%s", issuerId, classSuffix);
    }
  }

  // See link below for more information on required properties
  // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardclass
  GiftCardClass newClass =
      new GiftCardClass()
          .setId(String.format("%s.%s", issuerId, classSuffix))
          .setIssuerName("Issuer name")
          .setReviewStatus("UNDER_REVIEW");

  GiftCardClass response = service.giftcardclass().insert(newClass).execute();

  System.out.println("Class insert response");
  System.out.println(response.toPrettyString());

  return response.getId();
}

PHP

To start your integration in PHP, refer to our complete code samples on GitHub.

/**
 * Create a class.
 *
 * @param string $issuerId The issuer ID being used for this request.
 * @param string $classSuffix Developer-defined unique ID for this pass class.
 *
 * @return string The pass class ID: "{$issuerId}.{$classSuffix}"
 */
public function createClass(string $issuerId, string $classSuffix)
{
  // Check if the class exists
  try {
    $this->service->giftcardclass->get("{$issuerId}.{$classSuffix}");

    print("Class {$issuerId}.{$classSuffix} already exists!");
    return "{$issuerId}.{$classSuffix}";
  } catch (Google\Service\Exception $ex) {
    if (empty($ex->getErrors()) || $ex->getErrors()[0]['reason'] != 'classNotFound') {
      // Something else went wrong...
      print_r($ex);
      return "{$issuerId}.{$classSuffix}";
    }
  }

  // See link below for more information on required properties
  // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardclass
  $newClass = new GiftCardClass([
    'id' => "{$issuerId}.{$classSuffix}",
    'issuerName' => 'Issuer name',
    'reviewStatus' => 'UNDER_REVIEW'
  ]);

  $response = $this->service->giftcardclass->insert($newClass);

  print "Class insert response\n";
  print_r($response);

  return $response->id;
}

Python

To start your integration in Python, refer to our complete code samples on GitHub.

def create_class(self, issuer_id: str, class_suffix: str) -> str:
    """Create a class.

    Args:
        issuer_id (str): The issuer ID being used for this request.
        class_suffix (str): Developer-defined unique ID for this pass class.

    Returns:
        The pass class ID: f"{issuer_id}.{class_suffix}"
    """

    # Check if the class exists
    try:
        self.client.giftcardclass().get(resourceId=f'{issuer_id}.{class_suffix}').execute()
    except HttpError as e:
        if e.status_code != 404:
            # Something else went wrong...
            print(e.error_details)
            return f'{issuer_id}.{class_suffix}'
    else:
        print(f'Class {issuer_id}.{class_suffix} already exists!')
        return f'{issuer_id}.{class_suffix}'

    # See link below for more information on required properties
    # https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardclass
    new_class = {
        'id': f'{issuer_id}.{class_suffix}',
        'issuerName': 'Issuer name',
        'reviewStatus': 'UNDER_REVIEW'
    }

    response = self.client.giftcardclass().insert(body=new_class).execute()

    print('Class insert response')
    print(response)

    return f'{issuer_id}.{class_suffix}'

C#

To start your integration in C#, refer to our complete code samples on GitHub.

/// <summary>
/// Create a class.
/// </summary>
/// <param name="issuerId">The issuer ID being used for this request.</param>
/// <param name="classSuffix">Developer-defined unique ID for this pass class.</param>
/// <returns>The pass class ID: "{issuerId}.{classSuffix}"</returns>
public string CreateClass(string issuerId, string classSuffix)
{
  // Check if the class exists
  Stream responseStream = service.Giftcardclass
      .Get($"{issuerId}.{classSuffix}")
      .ExecuteAsStream();

  StreamReader responseReader = new StreamReader(responseStream);
  JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());

  if (!jsonResponse.ContainsKey("error"))
  {
    Console.WriteLine($"Class {issuerId}.{classSuffix} already exists!");
    return $"{issuerId}.{classSuffix}";
  }
  else if (jsonResponse["error"].Value<int>("code") != 404)
  {
    // Something else went wrong...
    Console.WriteLine(jsonResponse.ToString());
    return $"{issuerId}.{classSuffix}";
  }

  // See link below for more information on required properties
  // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardclass
  GiftCardClass newClass = new GiftCardClass
  {
    Id = $"{issuerId}.{classSuffix}",
    IssuerName = "Issuer name",
    ReviewStatus = "UNDER_REVIEW"
  };

  responseStream = service.Giftcardclass
      .Insert(newClass)
      .ExecuteAsStream();

  responseReader = new StreamReader(responseStream);
  jsonResponse = JObject.Parse(responseReader.ReadToEnd());

  Console.WriteLine("Class insert response");
  Console.WriteLine(jsonResponse.ToString());

  return $"{issuerId}.{classSuffix}";
}

Node.js

To start your integration in Node, refer to our complete code samples on GitHub.

/**
 * Create a class.
 *
 * @param {string} issuerId The issuer ID being used for this request.
 * @param {string} classSuffix Developer-defined unique ID for this pass class.
 *
 * @returns {string} The pass class ID: `${issuerId}.${classSuffix}`
 */
async createClass(issuerId, classSuffix) {
  let response;

  // Check if the class exists
  try {
    response = await this.client.giftcardclass.get({
      resourceId: `${issuerId}.${classSuffix}`
    });

    console.log(`Class ${issuerId}.${classSuffix} already exists!`);

    return `${issuerId}.${classSuffix}`;
  } catch (err) {
    if (err.response && err.response.status !== 404) {
      // Something else went wrong...
      console.log(err);
      return `${issuerId}.${classSuffix}`;
    }
  }

  // See link below for more information on required properties
  // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardclass
  let newClass = {
    'id': `${issuerId}.${classSuffix}`,
    'issuerName': 'Issuer name',
    'reviewStatus': 'UNDER_REVIEW',
  };

  response = await this.client.giftcardclass.insert({
    requestBody: newClass
  });

  console.log('Class insert response');
  console.log(response);

  return `${issuerId}.${classSuffix}`;
}

Go

To start your integration in Go, refer to our complete code samples on GitHub code samples on Github.

// Create a class.
func (d *demoGiftcard) createClass(issuerId, classSuffix string) {
	giftcardClass := new(walletobjects.GiftCardClass)
	giftcardClass.Id = fmt.Sprintf("%s.%s", issuerId, classSuffix)
	giftcardClass.IssuerName = "Issuer name"
	giftcardClass.ReviewStatus = "UNDER_REVIEW"
	res, err := d.service.Giftcardclass.Insert(giftcardClass).Do()
	if err != nil {
		log.Fatalf("Unable to insert class: %v", err)
	} else {
		fmt.Printf("Class insert id:\n%v\n", res.Id)
	}
}

Create a Passes Object

A Passes Object is an instance of a Passes Class. In order to create a Passes Object, you must provide the following attributes:

  • classId: The id of the Passes Class
  • id: A unique ID for your customer

    Refer to the Layout template for more information on how these attributes are represented in the gift card.

    Code sample to create a Passes Object:

    Java

    To start your integration in Java, refer to our complete code samples on GitHub.

    /**
     * Create an object.
     *
     * @param issuerId The issuer ID being used for this request.
     * @param classSuffix Developer-defined unique ID for this pass class.
     * @param objectSuffix Developer-defined unique ID for this pass object.
     * @return The pass object ID: "{issuerId}.{objectSuffix}"
     */
    public String createObject(String issuerId, String classSuffix, String objectSuffix)
        throws IOException {
      // Check if the object exists
      try {
        service.giftcardobject().get(String.format("%s.%s", issuerId, objectSuffix)).execute();
    
        System.out.printf("Object %s.%s already exists!%n", issuerId, objectSuffix);
        return String.format("%s.%s", issuerId, objectSuffix);
      } catch (GoogleJsonResponseException ex) {
        if (ex.getStatusCode() != 404) {
          // Something else went wrong...
          ex.printStackTrace();
          return String.format("%s.%s", issuerId, objectSuffix);
        }
      }
    
      // See link below for more information on required properties
      // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardobject
      GiftCardObject newObject =
          new GiftCardObject()
              .setId(String.format("%s.%s", issuerId, objectSuffix))
              .setClassId(String.format("%s.%s", issuerId, classSuffix))
              .setState("ACTIVE")
              .setHeroImage(
                  new Image()
                      .setSourceUri(
                          new ImageUri()
                              .setUri(
                                  "https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg"))
                      .setContentDescription(
                          new LocalizedString()
                              .setDefaultValue(
                                  new TranslatedString()
                                      .setLanguage("en-US")
                                      .setValue("Hero image description"))))
              .setTextModulesData(
                      List.of(
                              new TextModuleData()
                                      .setHeader("Text module header")
                                      .setBody("Text module body")
                                      .setId("TEXT_MODULE_ID")))
              .setLinksModuleData(
                  new LinksModuleData()
                      .setUris(
                          Arrays.asList(
                              new Uri()
                                  .setUri("http://maps.google.com/")
                                  .setDescription("Link module URI description")
                                  .setId("LINK_MODULE_URI_ID"),
                              new Uri()
                                  .setUri("tel:6505555555")
                                  .setDescription("Link module tel description")
                                  .setId("LINK_MODULE_TEL_ID"))))
              .setImageModulesData(
                      List.of(
                              new ImageModuleData()
                                      .setMainImage(
                                              new Image()
                                                      .setSourceUri(
                                                              new ImageUri()
                                                                      .setUri(
                                                                              "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg"))
                                                      .setContentDescription(
                                                              new LocalizedString()
                                                                      .setDefaultValue(
                                                                              new TranslatedString()
                                                                                      .setLanguage("en-US")
                                                                                      .setValue("Image module description"))))
                                      .setId("IMAGE_MODULE_ID")))
              .setBarcode(new Barcode().setType("QR_CODE").setValue("QR code value"))
              .setLocations(
                      List.of(
                              new LatLongPoint()
                                      .setLatitude(37.424015499999996)
                                      .setLongitude(-122.09259560000001)))
              .setCardNumber("Card number")
              .setPin("1234")
              .setBalance(new Money().setMicros(20000000L).setCurrencyCode("USD"))
              .setBalanceUpdateTime(new DateTime().setDate("2020-04-12T16:20:50.52-04:00"));
    
      GiftCardObject response = service.giftcardobject().insert(newObject).execute();
    
      System.out.println("Object insert response");
      System.out.println(response.toPrettyString());
    
      return response.getId();
    }
    

    PHP

    To start your integration in PHP, refer to our complete code samples on GitHub.

    /**
     * Create an object.
     *
     * @param string $issuerId The issuer ID being used for this request.
     * @param string $classSuffix Developer-defined unique ID for this pass class.
     * @param string $objectSuffix Developer-defined unique ID for this pass object.
     *
     * @return string The pass object ID: "{$issuerId}.{$objectSuffix}"
     */
    public function createObject(string $issuerId, string $classSuffix, string $objectSuffix)
    {
      // Check if the object exists
      try {
        $this->service->eventticketobject->get("{$issuerId}.{$objectSuffix}");
    
        print("Object {$issuerId}.{$objectSuffix} already exists!");
        return "{$issuerId}.{$objectSuffix}";
      } catch (Google\Service\Exception $ex) {
        if (empty($ex->getErrors()) || $ex->getErrors()[0]['reason'] != 'resourceNotFound') {
          // Something else went wrong...
          print_r($ex);
          return "{$issuerId}.{$objectSuffix}";
        }
      }
    
      // See link below for more information on required properties
      // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardobject
      $newObject = new GiftCardObject([
        'id' => "{$issuerId}.{$objectSuffix}",
        'classId' => "{$issuerId}.{$classSuffix}",
        'state' => 'ACTIVE',
        'heroImage' => new Image([
          'sourceUri' => new ImageUri([
            'uri' => 'https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg'
          ]),
          'contentDescription' => new LocalizedString([
            'defaultValue' => new TranslatedString([
              'language' => 'en-US',
              'value' => 'Hero image description'
            ])
          ])
        ]),
        'textModulesData' => [
          new TextModuleData([
            'header' => 'Text module header',
            'body' => 'Text module body',
            'id' => 'TEXT_MODULE_ID'
          ])
        ],
        'linksModuleData' => new LinksModuleData([
          'uris' => [
            new Uri([
              'uri' => 'http://maps.google.com/',
              'description' => 'Link module URI description',
              'id' => 'LINK_MODULE_URI_ID'
            ]),
            new Uri([
              'uri' => 'tel:6505555555',
              'description' => 'Link module tel description',
              'id' => 'LINK_MODULE_TEL_ID'
            ])
          ]
        ]),
        'imageModulesData' => [
          new ImageModuleData([
            'mainImage' => new Image([
              'sourceUri' => new ImageUri([
                'uri' => 'http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg'
              ]),
              'contentDescription' => new LocalizedString([
                'defaultValue' => new TranslatedString([
                  'language' => 'en-US',
                  'value' => 'Image module description'
                ])
              ])
            ]),
            'id' => 'IMAGE_MODULE_ID'
          ])
        ],
        'barcode' => new Barcode([
          'type' => 'QR_CODE',
          'value' => 'QR code value'
        ]),
        'locations' => [
          new LatLongPoint([
            'latitude' => 37.424015499999996,
            'longitude' =>  -122.09259560000001
          ])
        ],
        'cardNumber' => 'Card number',
        'pin' => '1234',
        'balance' => new Money([
          'micros' => 20000000,
          'currencyCode' => 'USD'
        ]),
        'balanceUpdateTime' => new DateTime([
          'date' => '2020-04-12T16:20:50.52-04:00'
        ])
      ]);
    
      $response = $this->service->giftcardobject->insert($newObject);
    
      print "Object insert response\n";
      print_r($response);
    
      return $response->id;
    }
    

    Python

    To start your integration in Python, refer to our complete code samples on GitHub.

    def create_object(self, issuer_id: str, class_suffix: str,
                      object_suffix: str) -> str:
        """Create an object.
    
        Args:
            issuer_id (str): The issuer ID being used for this request.
            class_suffix (str): Developer-defined unique ID for the pass class.
            object_suffix (str): Developer-defined unique ID for the pass object.
    
        Returns:
            The pass object ID: f"{issuer_id}.{object_suffix}"
        """
    
        # Check if the object exists
        try:
            self.client.giftcardobject().get(resourceId=f'{issuer_id}.{object_suffix}').execute()
        except HttpError as e:
            if e.status_code != 404:
                # Something else went wrong...
                print(e.error_details)
                return f'{issuer_id}.{object_suffix}'
        else:
            print(f'Object {issuer_id}.{object_suffix} already exists!')
            return f'{issuer_id}.{object_suffix}'
    
        # See link below for more information on required properties
        # https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardobject
        new_object = {
            'id': f'{issuer_id}.{object_suffix}',
            'classId': f'{issuer_id}.{class_suffix}',
            'state': 'ACTIVE',
            'heroImage': {
                'sourceUri': {
                    'uri':
                        'https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg'
                },
                'contentDescription': {
                    'defaultValue': {
                        'language': 'en-US',
                        'value': 'Hero image description'
                    }
                }
            },
            'textModulesData': [{
                'header': 'Text module header',
                'body': 'Text module body',
                'id': 'TEXT_MODULE_ID'
            }],
            'linksModuleData': {
                'uris': [{
                    'uri': 'http://maps.google.com/',
                    'description': 'Link module URI description',
                    'id': 'LINK_MODULE_URI_ID'
                }, {
                    'uri': 'tel:6505555555',
                    'description': 'Link module tel description',
                    'id': 'LINK_MODULE_TEL_ID'
                }]
            },
            'imageModulesData': [{
                'mainImage': {
                    'sourceUri': {
                        'uri':
                            'http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg'
                    },
                    'contentDescription': {
                        'defaultValue': {
                            'language': 'en-US',
                            'value': 'Image module description'
                        }
                    }
                },
                'id': 'IMAGE_MODULE_ID'
            }],
            'barcode': {
                'type': 'QR_CODE',
                'value': 'QR code'
            },
            'locations': [{
                'latitude': 37.424015499999996,
                'longitude': -122.09259560000001
            }],
            'cardNumber': 'Card number',
            'pin': '1234',
            'balance': {
                'micros': 20000000,
                'currencyCode': 'USD'
            },
            'balanceUpdateTime': {
                'date': '2020-04-12T16:20:50.52-04:00'
            }
        }
    
        # Create the object
        response = self.client.giftcardobject().insert(body=new_object).execute()
    
        print('Object insert response')
        print(response)
    
        return f'{issuer_id}.{object_suffix}'
    
    

    C#

    To start your integration in C#, refer to our complete code samples on GitHub.

    /// <summary>
    /// Create an object.
    /// </summary>
    /// <param name="issuerId">The issuer ID being used for this request.</param>
    /// <param name="classSuffix">Developer-defined unique ID for this pass class.</param>
    /// <param name="objectSuffix">Developer-defined unique ID for this pass object.</param>
    /// <returns>The pass object ID: "{issuerId}.{objectSuffix}"</returns>
    public string CreateObject(string issuerId, string classSuffix, string objectSuffix)
    {
      // Check if the object exists
      Stream responseStream = service.Giftcardobject
          .Get($"{issuerId}.{objectSuffix}")
          .ExecuteAsStream();
    
      StreamReader responseReader = new StreamReader(responseStream);
      JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());
    
      if (!jsonResponse.ContainsKey("error"))
      {
        Console.WriteLine($"Object {issuerId}.{objectSuffix} already exists!");
        return $"{issuerId}.{objectSuffix}";
      }
      else if (jsonResponse["error"].Value<int>("code") != 404)
      {
        // Something else went wrong...
        Console.WriteLine(jsonResponse.ToString());
        return $"{issuerId}.{objectSuffix}";
      }
    
      // See link below for more information on required properties
      // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardobject
      GiftCardObject newObject = new GiftCardObject
      {
        Id = $"{issuerId}.{objectSuffix}",
        ClassId = $"{issuerId}.{classSuffix}",
        State = "ACTIVE",
        HeroImage = new Image
        {
          SourceUri = new ImageUri
          {
            Uri = "https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg"
          },
          ContentDescription = new LocalizedString
          {
            DefaultValue = new TranslatedString
            {
              Language = "en-US",
              Value = "Hero image description"
            }
          }
        },
        TextModulesData = new List<TextModuleData>
        {
          new TextModuleData
          {
            Header = "Text module header",
            Body = "Text module body",
            Id = "TEXT_MODULE_ID"
          }
        },
        LinksModuleData = new LinksModuleData
        {
          Uris = new List<Google.Apis.Walletobjects.v1.Data.Uri>
          {
            new Google.Apis.Walletobjects.v1.Data.Uri
            {
              UriValue = "http://maps.google.com/",
              Description = "Link module URI description",
              Id = "LINK_MODULE_URI_ID"
            },
            new Google.Apis.Walletobjects.v1.Data.Uri
            {
              UriValue = "tel:6505555555",
              Description = "Link module tel description",
              Id = "LINK_MODULE_TEL_ID"
            }
          }
        },
        ImageModulesData = new List<ImageModuleData>
        {
          new ImageModuleData
          {
            MainImage = new Image
            {
              SourceUri = new ImageUri
              {
                Uri = "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg"
              },
              ContentDescription = new LocalizedString
              {
                DefaultValue = new TranslatedString
                {
                  Language = "en-US",
                  Value = "Image module description"
                }
              }
            },
            Id = "IMAGE_MODULE_ID"
          }
        },
        Barcode = new Barcode
        {
          Type = "QR_CODE",
          Value = "QR code"
        },
        Locations = new List<LatLongPoint>
        {
          new LatLongPoint
          {
            Latitude = 37.424015499999996,
            Longitude = -122.09259560000001
          }
        },
        CardNumber = "Card number",
        Pin = "1234",
        Balance = new Money
        {
          Micros = 20000000,
          CurrencyCode = "USD"
        },
        BalanceUpdateTime = new Google.Apis.Walletobjects.v1.Data.DateTime
        {
          Date = "2020-04-12T16:20:50.52-04:00"
        }
      };
    
      responseStream = service.Giftcardobject
          .Insert(newObject)
          .ExecuteAsStream();
      responseReader = new StreamReader(responseStream);
      jsonResponse = JObject.Parse(responseReader.ReadToEnd());
    
      Console.WriteLine("Object insert response");
      Console.WriteLine(jsonResponse.ToString());
    
      return $"{issuerId}.{objectSuffix}";
    }
    

    Node.js

    To start your integration in Node, refer to our complete code samples on GitHub.

    /**
     * Create an object.
     *
     * @param {string} issuerId The issuer ID being used for this request.
     * @param {string} classSuffix Developer-defined unique ID for the pass class.
     * @param {string} objectSuffix Developer-defined unique ID for the pass object.
     *
     * @returns {string} The pass object ID: `${issuerId}.${objectSuffix}`
     */
    async createObject(issuerId, classSuffix, objectSuffix) {
      let response;
    
      // Check if the object exists
      try {
        response = await this.client.giftcardobject.get({
          resourceId: `${issuerId}.${objectSuffix}`
        });
    
        console.log(`Object ${issuerId}.${objectSuffix} already exists!`);
    
        return `${issuerId}.${objectSuffix}`;
      } catch (err) {
        if (err.response && err.response.status !== 404) {
          // Something else went wrong...
          console.log(err);
          return `${issuerId}.${objectSuffix}`;
        }
      }
    
      // See link below for more information on required properties
      // https://developers.google.com/wallet/retail/gift-cards/rest/v1/giftcardobject
      let newObject = {
        'id': `${issuerId}.${objectSuffix}`,
        'classId': `${issuerId}.${classSuffix}`,
        'state': 'ACTIVE',
        'heroImage': {
          'sourceUri': {
            'uri': 'https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg'
          },
          'contentDescription': {
            'defaultValue': {
              'language': 'en-US',
              'value': 'Hero image description'
            }
          }
        },
        'textModulesData': [
          {
            'header': 'Text module header',
            'body': 'Text module body',
            'id': 'TEXT_MODULE_ID'
          }
        ],
        'linksModuleData': {
          'uris': [
            {
              'uri': 'http://maps.google.com/',
              'description': 'Link module URI description',
              'id': 'LINK_MODULE_URI_ID'
            },
            {
              'uri': 'tel:6505555555',
              'description': 'Link module tel description',
              'id': 'LINK_MODULE_TEL_ID'
            }
          ]
        },
        'imageModulesData': [
          {
            'mainImage': {
              'sourceUri': {
                'uri': 'http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg'
              },
              'contentDescription': {
                'defaultValue': {
                  'language': 'en-US',
                  'value': 'Image module description'
                }
              }
            },
            'id': 'IMAGE_MODULE_ID'
          }
        ],
        'barcode': {
          'type': 'QR_CODE',
          'value': 'QR code'
        },
        'locations': [
          {
            'latitude': 37.424015499999996,
            'longitude': -122.09259560000001
          }
        ],
        'cardNumber': 'Card number',
        'pin': '1234',
        'balance': {
          'micros': 20000000,
          'currencyCode': 'USD'
        },
        'balanceUpdateTime': {
          'date': '2020-04-12T16:20:50.52-04:00'
        }
      };
    
      response = await this.client.giftcardobject.insert({
        requestBody: newObject
      });
    
      console.log('Object insert response');
      console.log(response);
    
      return `${issuerId}.${objectSuffix}`;
    }
    

    Go

    To start your integration in Go, refer to our complete code samples on GitHub code samples on Github.

    // Create an object.
    func (d *demoGiftcard) createObject(issuerId, classSuffix, objectSuffix string) {
    	giftcardObject := new(walletobjects.GiftCardObject)
    	giftcardObject.Id = fmt.Sprintf("%s.%s", issuerId, objectSuffix)
    	giftcardObject.ClassId = fmt.Sprintf("%s.%s", issuerId, classSuffix)
    	giftcardObject.State = "ACTIVE"
    	giftcardObject.CardNumber = "Card number"
    	giftcardObject.Pin = "1234"
    	giftcardObject.Balance = &walletobjects.Money{
    		Micros:       20000000,
    		CurrencyCode: "USD",
    	}
    	giftcardObject.BalanceUpdateTime = &walletobjects.DateTime{
    		Date: "2023-12-12T23:20:50.52Z",
    	}
    	giftcardObject.HeroImage = &walletobjects.Image{
    		SourceUri: &walletobjects.ImageUri{
    			Uri: "https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg",
    		},
    	}
    	giftcardObject.Barcode = &walletobjects.Barcode{
    		Type:  "QR_CODE",
    		Value: "QR code",
    	}
    	giftcardObject.Locations = []*walletobjects.LatLongPoint{
    		&walletobjects.LatLongPoint{
    			Latitude:  37.424015499999996,
    			Longitude: -122.09259560000001,
    		},
    	}
    	giftcardObject.LinksModuleData = &walletobjects.LinksModuleData{
    		Uris: []*walletobjects.Uri{
    			&walletobjects.Uri{
    				Id:          "LINK_MODULE_URI_ID",
    				Uri:         "http://maps.google.com/",
    				Description: "Link module URI description",
    			},
    			&walletobjects.Uri{
    				Id:          "LINK_MODULE_TEL_ID",
    				Uri:         "tel:6505555555",
    				Description: "Link module tel description",
    			},
    		},
    	}
    	giftcardObject.ImageModulesData = []*walletobjects.ImageModuleData{
    		&walletobjects.ImageModuleData{
    			Id: "IMAGE_MODULE_ID",
    			MainImage: &walletobjects.Image{
    				SourceUri: &walletobjects.ImageUri{
    					Uri: "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg",
    				},
    			},
    		},
    	}
    	giftcardObject.TextModulesData = []*walletobjects.TextModuleData{
    		&walletobjects.TextModuleData{
    			Body:   "Text module body",
    			Header: "Text module header",
    			Id:     "TEXT_MODULE_ID",
    		},
    	}
    
    	res, err := d.service.Giftcardobject.Insert(giftcardObject).Do()
    	if err != nil {
    		log.Fatalf("Unable to insert object: %v", err)
    	} else {
    		fmt.Printf("Object insert id:\n%s\n", res.Id)
    	}
    }
    
    

    Once complete, your customer's Passes Object will have been created on the server. However, at this stage, the Passes Object has not been linked to a Google user or their device. For the pass to be associated with a Google Wallet user, you must issue the pass.