卡券对象的每个实例都需要指定 id 属性。该对象 ID
用作唯一标识符,供您在向用户签发卡券时参考。
卡券类如何与卡券对象配合使用
卡券对象必须通过引用其类 ID 或包含完整的卡券类定义来扩展卡券类的实例。卡券类和卡券对象实例之间的这种关系
表示您可以通过卡券类实例来设置和更新所有已发放卡券通用的属性,
和属性。
例如,在下面这个简单的“活动门票”卡券图表中,我们展示了在共享 EventTicketClass 中定义的字段与 EventTicketObject 中定义的特定门票字段的组合方式,以构建最终发放的卡券。请注意卡券类的 ID 是如何在卡券对象的 classId 属性中引用的。
对卡券类实例所做的更改将立即传播到所有卡券对象实例
引用它的对象。用户将看到您对卡券类实例所做的任何更改都会体现出来
Google 钱包应用中的卡券。
将卡券添加到用户的 Google 钱包
如需将卡券添加到用户的 Google 钱包,您需要创建一个包含声明的 JSON 网络令牌 (JWT)
您(发卡机构)针对将保存在用户 Google 钱包中的卡券对象实例进行构建 -
最重要的是,您要向用户发出的卡券对象实例的对象 ID。JWT
系统随后会通过添加到 Google 钱包按钮或添加到 Google 钱包将该应用发送给用户
链接。
当用户点击将已发放的卡券添加到 Google 钱包中的按钮或链接后,
编码到 JWT 中的卡券对象实例与该用户的 Google 账号相关联。这意味着
当用户再次点击该按钮时,该卡券对象的链接已存在,因此重复
副本将不会添加到用户的电子钱包中。
如果用户从 Google 钱包应用中移除卡券,相应的卡券对象实例为
它会自动解除与用户的关联,但不会将其删除。也就是说,用户可以点击
添加到 Google 钱包按钮或重新关联,即可保存卡券,无需
需要创建新的卡券对象实例或 JWT。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eGoogle Wallet passes are built using two components: Passes Classes (templates for shared pass properties) and Passes Objects (defining unique pass details).\u003c/p\u003e\n"],["\u003cp\u003ePasses Classes act like blueprints for multiple passes, holding common information like event venue, issuer, and date.\u003c/p\u003e\n"],["\u003cp\u003ePasses Objects store individual pass data, such as seat numbers for event tickets, referencing their corresponding Passes Class.\u003c/p\u003e\n"],["\u003cp\u003eUpdating a Passes Class instantly reflects changes across all associated passes in users' Google Wallets upon syncing.\u003c/p\u003e\n"],["\u003cp\u003ePasses are added to a user's Google Wallet through a JWT containing the Passes Object ID, accessible via "Add to Google Wallet" buttons or links.\u003c/p\u003e\n"]]],["Google Wallet passes rely on Passes Classes and Passes Objects. Classes act as templates, defining shared properties (e.g., event name, venue) via a unique Class ID. Objects contain unique pass details (e.g., seat number), referencing the Class ID. Issuers create a JSON Web Token (JWT) with the Object ID and provide an \"Add to Google Wallet\" button or link to deliver it. User interactions link/de-link the object in the user's wallet, but doesn't delete it. Class updates propagate to linked Objects.\n"],null,["# Passes Classes and Objects overview\n\nAlmost 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.\n\nThe 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.\n\nEach 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.\n\nPasses Classes\n--------------\n\nThink of a Passes Class as a shared template that is used to create one or more passes\nyou will issue to your users. A Passes Class defines a common set of properties that will be included\nin all passes that reference it.\n\nFor example, the following instance of the `EventTicketClass` defines the fields that are common to all issued tickets for an upcoming event(venue, event name, issuer, date/time). \n\n```\n{\n \"id\": \"ISSUER_ID.EVENT_CLASS_ID\",\n \"issuerName\": \"[TEST ONLY] Heraldic Event\",\n \"localizedIssuerName\": {\n \"defaultValue\": {\n \"language\": \"en-US\",\n \"value\": \"[TEST ONLY] Heraldic Event\"\n }\n },\n \"eventName\": {\n \"defaultValue\": {\n \"language\": \"en-US\",\n \"value\": \"Google Live\"\n }\n },\n \"venue\": {\n \"name\": {\n \"defaultValue\": {\n \"language\": \"en-US\",\n \"value\": \"Shoreline Amphitheater\"\n }\n },\n \"address\": {\n \"defaultValue\": {\n \"language\": \"en-US\",\n \"value\": \"ADDRESS_OF_THE_VENUE\"\n }\n }\n },\n \"dateTime\": {\n \"start\": \"2023-04-12T11:30\"\n },\n \"reviewStatus\": \"UNDER_REVIEW\"\n}\n \n```\n\nEach instance of a Passes Class requires an `id` property, which you specify. This Class ID\nacts as a unique identifier that you will reference whenever you use it to create a new Passes Object\ninstance.\n\nPasses Objects\n--------------\n\nWhile an instance of a Passes Class specifies a set of shared properties to be used in one or more\npasses, a Passes Object specifies the unique details of a specific pass that is issued to a specific user.\n\nFor example, when an Event Ticket Pass is created with the Google Wallet API, an `EventTicketObject`\ninstance includes properties for the seat assigned to that ticket since those values will be unique to each\nticket issued. \n\n```\n{\n \"id\": \"ISSUER_ID.OBJECT_ID\",\n \"classId\": \"ISSUER_ID.EVENT_CLASS_ID\",\n \"state\": \"ACTIVE\",\n \"seatInfo\": {\n \"seat\": {\n \"defaultValue\": {\n \"language\": \"en-us\",\n \"value\": \"9\"\n }\n },\n \"row\": {\n \"defaultValue\": {\n \"language\": \"en-us\",\n \"value\": \"L\"\n }\n },\n \"section\": {\n \"defaultValue\": {\n \"language\": \"en-us\",\n \"value\": \"45\"\n }\n },\n \"gate\": {\n \"defaultValue\": {\n \"language\": \"en-us\",\n \"value\": \"7C\"\n }\n }\n },\n \"barcode\": {\n \"type\": \"BARCODE_TYPE_UNSPECIFIED\",\n \"value\": \"BARCODE_VALUE\",\n \"alternateText\": \"\"\n }\n}\n \n```\n\nEach instance of a Passes Object requires an `id` property, which you specify. This Object ID\nacts as a unique identifier that you will reference when you issue the pass to a user.\n\nHow Passes Classes work with Passes Objects\n-------------------------------------------\n\nPasses Objects must extend an instance of a Passes Class either by referencing its Class ID or including the full Passes Class definition. This relationship between a Passes Class and Passes Object instance\nmeans you can set and update properties that are common to all issued passes via the Passes Class instance,\nand properties unique to an individual pass in the Passes Object instance.\n\nFor example, the following diagram of a simple Event Ticket pass shows how the fields that are defined in the shared `EventTicketClass`, and the fields for a specific ticket defined in the `EventTicketObject` combine to construct the final issued pass. Note how the ID of the Passes Class is referenced in `classId` property of the Passes Object.\n\nChanges made to a Passes Class instance instance will propagate immediately across all Passes Object instances\nthat reference it. Users will see any changes you make to a Passes Class instance reflected\non the pass in their Google Wallet app the next time they sync.\n\nAdding a pass to a user's Google Wallet\n---------------------------------------\n\nTo add a pass to a user's Google Wallet, you create a JSON Web Token (JWT) that contains claims\nyou (the issuer) are making about the Passes Object instance that will be saved in the user's Google Wallet -\nmost importantly, the Object ID of the Passes Object instance you are issuing to the user. The JWT\nis then delivered to the user via the a **Add to Google Wallet** button or an **Add to Google Wallet**\nlink.\n\nAfter a user clicks the button or link to add an issued pass into their Google Wallet, a link the\nPasses Object instance encoded in the JWT is linked to that user's Google account. This means that\nwhen the user clicks the button again, a link already exists to that Passes Object, so duplicate\ncopies won't be added to the user's wallet.\n\nIf a user removes a pass from the Google Wallet app, the corresponding Passes Object instance is\nautomatically de-linked from the user, but it is not deleted. This means that a user can click the\n**Add to Google Wallet** button or link again, to save the pass without the need for a\nnew Passes Object instance or JWT to be created."]]