如要將票證新增到使用者的 Google 錢包,請建立含有憑證附加資訊的 JSON Web Token (JWT)
您 (發卡機構) 要針對即將儲存至使用者 Google 錢包的票證物件執行個體建立要求:
最重要的是,您要核發給使用者的票證物件執行個體物件 ID。JWT
隨後,使用者按一下「新增至 Google 錢包」按鈕或「新增至 Google 錢包」,
連結。
使用者點選按鈕或連結,將已核發的票證新增至 Google 錢包後,
在 JWT 中編碼的物件執行個體會連結至該使用者的 Google 帳戶。也就是說
當使用者再次點選該按鈕時,該票證物件已有連結,因此重複點選
副本將不會新增到使用者的錢包。
使用者從 Google 錢包應用程式中移除票證後,系統會將相應的票證物件例項
自動解除連結,但不會刪除。也就是說,使用者可以點選
再次「新增至 Google 錢包」按鈕或連結,即可輕鬆儲存票證,省去麻煩
新的 Passes 物件執行個體或 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"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[[["\u003cp\u003eGoogle Wallet passes are built using two components: Passes Classes (templates for shared pass properties) and Passes Objects (unique details for individual passes).\u003c/p\u003e\n"],["\u003cp\u003ePasses Classes define common pass details like event name or issuer, while Passes Objects include unique information like seat numbers or gift card balances.\u003c/p\u003e\n"],["\u003cp\u003ePasses Objects are linked to Passes Classes, allowing updates to the class to instantly propagate to all associated passes in users' wallets.\u003c/p\u003e\n"],["\u003cp\u003eAdding a pass to Google Wallet involves creating a JWT containing the pass details, which users access via an "Add to Google Wallet" button or link.\u003c/p\u003e\n"],["\u003cp\u003eRemoving a pass from Google Wallet simply unlinks it from the user's account; the pass can be re-added later without creating a new pass instance.\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."]]