パスのクラスとオブジェクトの概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
エンドユーザーが発行して Google ウォレットに保存できるパスのほとんどは、パスクラスとパス オブジェクトの 2 つのコンポーネントで定義されます。ユーザーにパスを発行するときは常に、パスクラスとパス オブジェクトの両方のインスタンスが必要になります。パスクラスは、作成するパスのタイプと、パスに表示する詳細情報(ギフトカードの金額やチケット所有者の名前など)を Google Wallet API に伝えるものです。
Google Wallet API には、パスクラスとパス オブジェクトの事前定義セットが用意されています。これらのセットのインスタンスを作成して、ユーザーに発行するパス(GiftCardClass
、GiftCardObject
、GenericClass
、GenericObject
など)の作成に使用します。
各パスクラスとパス オブジェクトのインスタンスは JSON オブジェクトとして定義されます。このオブジェクトには、そのパスタイプを対象とする特定のユースケースに対応する必須のプロパティとオプションのプロパティのセットが含まれています。
パスクラス
パスクラスは、1 つ以上のパスの作成に使用される共有テンプレートと考える
ユーザーに発行しますパスクラスは、含まれるプロパティ セットを定義します
すべてのパスでこれを参照するためです。
たとえば、次の EventTicketClass
のインスタンスは、今後のイベントで発行されたすべてのチケットに共通するフィールド(会場、イベント名、発行者、日時)を定義しています。
{
"id": "ISSUER_ID.EVENT_CLASS_ID",
"issuerName": "[TEST ONLY] Heraldic Event",
"localizedIssuerName": {
"defaultValue": {
"language": "en-US",
"value": "[TEST ONLY] Heraldic Event"
}
},
"eventName": {
"defaultValue": {
"language": "en-US",
"value": "Google Live"
}
},
"venue": {
"name": {
"defaultValue": {
"language": "en-US",
"value": "Shoreline Amphitheater"
}
},
"address": {
"defaultValue": {
"language": "en-US",
"value": "ADDRESS_OF_THE_VENUE"
}
}
},
"dateTime": {
"start": "2023-04-12T11:30"
},
"reviewStatus": "UNDER_REVIEW"
}
パスクラスの各インスタンスには、指定する id
プロパティが必要です。このクラス ID
固有の識別子として機能します。この識別子を使用して新しいパス オブジェクトを作成する際には、この識別子が参照されます。
作成します。
パス オブジェクト
パスクラスのインスタンスは、1 つ以上のパスで使用する一連の共有プロパティを指定します。
パス オブジェクトでは、特定のユーザーに発行される特定のパスの固有の詳細を指定します。
たとえば、Google Wallet API でイベント チケットパスを作成すると、EventTicketObject
インスタンスには、そのチケットに割り当てられた座席のプロパティが含まれます。これらの値は各座席に一意であるため、
発行されます。
{
"id": "ISSUER_ID.OBJECT_ID",
"classId": "ISSUER_ID.EVENT_CLASS_ID",
"state": "ACTIVE",
"seatInfo": {
"seat": {
"defaultValue": {
"language": "en-us",
"value": "9"
}
},
"row": {
"defaultValue": {
"language": "en-us",
"value": "L"
}
},
"section": {
"defaultValue": {
"language": "en-us",
"value": "45"
}
},
"gate": {
"defaultValue": {
"language": "en-us",
"value": "7C"
}
}
},
"barcode": {
"type": "BARCODE_TYPE_UNSPECIFIED",
"value": "BARCODE_VALUE",
"alternateText": ""
}
}
パス オブジェクトの各インスタンスには、指定する id
プロパティが必要です。このオブジェクト ID
は、ユーザーにパスを発行するときに参照する一意の識別子として機能します。
パスクラスとパス オブジェクトの連携
パス オブジェクトは、クラス ID を参照するか、パスクラスの完全な定義を含めることで、パスクラスのインスタンスを拡張する必要があります。パスクラスとパス オブジェクト インスタンスの関係
つまり、パスクラスのインスタンスを介して発行されたすべてのパスに共通するプロパティを設定および更新できます。
パス オブジェクト インスタンスの個々のパスに固有のプロパティとプロパティを指定します。
たとえば、以下のシンプルなイベント チケット パスの図は、共有 EventTicketClass
で定義されたフィールドと、EventTicketObject
で定義された特定のチケットのフィールドを組み合わせて、最終的に発行されたパスを作成する方法を示しています。パスクラスの ID がパス オブジェクトの classId
プロパティで参照されていることに注意してください。
パスクラスのインスタンスに加えた変更は、すべてのパス オブジェクトのインスタンスにすぐに反映されます
参照します。パスクラスのインスタンスに加えた変更は、ユーザーに反映されます。
次回の同期時に Google ウォレット アプリのパスに表示されます。
ユーザーの Google ウォレットにパスを追加する
ユーザーの Google ウォレットにパスを追加するには、クレームを含む JSON Web Token(JWT)を作成します。
ユーザーの Google ウォレットに保存されるパス オブジェクト インスタンスについて、発行元が作成したもの
最も重要なのは、ユーザーに発行するパス オブジェクト インスタンスのオブジェクト ID です。JWT
その後、[Google ウォレットに追加] ボタンまたは [Google ウォレットに追加] を介してユーザーに配信されます。
表示されます。
ユーザーが発行済みのパスを Google ウォレットに追加するボタンまたはリンクをクリックすると、
JWT でエンコードされたパス オブジェクト インスタンスは、そのユーザーの Google アカウントにリンクされます。つまり
ユーザーがボタンをもう一度クリックすると、そのパス オブジェクトへのリンクがすでに存在するため、重複します。
コピーはユーザーのウォレットには追加されません。
ユーザーが Google ウォレット アプリからパスを削除すると、対応するパス オブジェクトのインスタンスは
ユーザーと自動的にリンクが解除されますが、削除されることはありません。つまりユーザーは
[Google ウォレットに追加] ボタンまたはリンクを再度クリックすると、
作成する新しいパス オブジェクト インスタンスまたは JWT。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-10 UTC。
[[["わかりやすい","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-10 UTC。"],[[["\u003cp\u003eGoogle Wallet passes are primarily defined by two components: a Passes Class (template for shared pass properties) and a Passes Object (unique details for an individual pass).\u003c/p\u003e\n"],["\u003cp\u003ePasses Classes act as blueprints for multiple passes, defining shared attributes like event venue or issuer name, while Passes Objects store unique data for each pass, such as seat numbers or ticket holder information.\u003c/p\u003e\n"],["\u003cp\u003eThe relationship between a Passes Class and Passes Object allows for efficient management and updates to passes, as changes to a class propagate to all associated objects.\u003c/p\u003e\n"],["\u003cp\u003eAdding a pass to a user's Google Wallet involves generating a JWT (JSON Web Token) containing claims about the pass, which links the pass to the user's Google account preventing duplication.\u003c/p\u003e\n"],["\u003cp\u003eRemoving a pass from Google Wallet simply unlinks it from the user's account; the pass data remains and 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."]]