Panoramica
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
L'API Google Wallet Passes consente ai partner di salvare
Rotazione
codici a barre a Google Wallet. Questi codici a barre sono validi solo per un breve periodo di tempo,
fornisce una sicurezza aggiuntiva per ridurre il rischio di screenshot dei codici a barre. La
i codici a barre siano generati sul dispositivo in conformità
RFC 6238, con il partner che fornisce i campi
chiave privata. Tuttavia, se un partner preferisce generare i codici a barre da solo, Google fornisce
un'API per il caricamento collettivo dei codici a barre su Google. Questi codici a barre
i dati verranno trasmessi all'utente telefoni, che agiranno come i codici a barre rotanti,
visualizzati per un breve periodo di tempo. Ci riferiamo a questa soluzione come generata dai partner
Rotazione dei codici a barre.
API di rotating Barcode generato dai partner
I codici a barre rotanti generati dai partner vengono creati utilizzando lo stesso
. È obbligatorio solo il tipo, anche se consigliamo di creare anche un piccolo comando iniziale
di codici a barre (del valore di circa 10 minuti) e l'invio
initialRotatingBarcodeValues
. Il partner ha la responsabilità di garantire
sempre un codice a barre valido pronto per l'utente e initialRotatingBarcodeValues
consente
la successiva chiamata al caricamento in batch.
rotatingBarcode {
initialRotatingBarcodeValues: object (RotatingBarcodeValues),
type: enum (BarcodeType),
}
Campo |
Descrizione |
initialRotatingBarcodeValues |
object (RotatingBarcodeValues)
I valori da codificare nel codice a barre. Almeno un valore è obbligatorio. Queste iniziali
i codici a barre servono a colmare il divario tra il momento in cui l'utente ottiene la tessera per la prima volta
quando viene effettuata la successiva chiamata di caricamento in batch.
|
type |
enum (BarcodeType)
Obbligatorio. Il tipo di questo codice a barre.
I valori accettati sono:
|
RotatingBarcodeValues
Campo |
Descrizione |
startDateTime |
string
La data e l'ora da cui è valido il primo codice a barre. I codici a barre verranno ruotati
utilizzando periodMillis .
Data/ora nel formato esteso ISO 8601 con offset.
|
values[] |
string
I valori da codificare nel codice a barre. Almeno un valore è obbligatorio.
Non esiste un numero massimo di valori, ma tieni presente che le dimensioni del corpo della richiesta
non può superare i 5 MB.
|
periodMillis |
number
La quantità di tempo di validità di ciascun codice a barre.
|
Aggiornamento collettivo dei valori dei codici a barre
Dopo la creazione dell'oggetto RotatingBarcode, consigliamo di caricare una
di codici a barre, ogni giorno, fino alla scadenza della tessera dell'utente. Questa operazione può essere eseguita con
seguendo l'endpoint API REST.
Metodo: transitobject.uploadrotatingbarcodevalues
Carica i valori del codice a barre in rotazione nell'oggetto di transito a cui fa riferimento l'ID oggetto specificato.
Richiesta HTTP
POST
https://walletobjects.googleapis.com/upload/walletobjects/v1/transitObject/{resourc
eId}/uploadRotatingBarcodeValues
Parametri del percorso
Parametro |
Descrizione |
resourceId |
string
L'identificatore univoco di un oggetto.
|
Corpo della richiesta
Il corpo della richiesta (che non può superare i 5 MB) contiene un'istanza di
RotatingBarcodeValues.
Metodo: transitobject.downloadrotatingbarcodevalues
Scarica i valori del codice a barre in rotazione per l'oggetto di transito a cui fa riferimento l'oggetto specificato
ID. Ciò è utile se i partner vogliono verificare il batch più recente.
Richiesta HTTP
GET
https://walletobjects.googleapis.com/walletobjects/v1/transitObject/{resourceId}/do
wnloadRotatingBarcodeValues?alt=media
Parametri del percorso
Parametro |
Descrizione |
resourceId |
string
L'identificatore univoco di un oggetto.
|
Meccanismi di fallback
Tieni presente che se un RotatingBarcode valido non ha codici a barre validi da visualizzare,
non sono stati ancora caricati o tutti i codici a barre correnti sono stati utilizzati), viene visualizzato un errore
verrà mostrato all'utente.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-25 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-25 UTC."],[[["\u003cp\u003eGoogle Wallet now supports Partner-Generated Rotating Barcodes for enhanced security, allowing partners to generate and upload time-limited barcodes directly.\u003c/p\u003e\n"],["\u003cp\u003ePartners can integrate Rotating Barcodes using the \u003ccode\u003erotatingBarcode\u003c/code\u003e object within the Google Wallet Passes API, specifying the barcode type and initial values.\u003c/p\u003e\n"],["\u003cp\u003eThe API provides methods for batch uploading (\u003ccode\u003etransitobject.uploadrotatingbarcodevalues\u003c/code\u003e) and downloading (\u003ccode\u003etransitobject.downloadrotatingbarcodevalues\u003c/code\u003e) barcode values for ongoing updates.\u003c/p\u003e\n"],["\u003cp\u003eTo ensure continuous barcode availability, it is recommended to upload a day's worth of barcodes daily until a user's pass expires, utilizing the \u003ccode\u003einitialRotatingBarcodeValues\u003c/code\u003e for a smooth initial experience.\u003c/p\u003e\n"],["\u003cp\u003eIf a Rotating Barcode lacks valid values, an error message will be displayed to the user, highlighting the importance of timely barcode updates.\u003c/p\u003e\n"]]],["The Google Wallet Passes API enables partners to use Partner-Generated Rotating Barcodes, enhancing security by having barcodes valid for a short time. Partners can define a `RotatingBarcode` object specifying the barcode `type` and `initialRotatingBarcodeValues`. They then batch upload barcode values using the `transitobject.uploadrotatingbarcodevalues` API endpoint and should upload a day's worth of barcodes each day. Barcode values can be downloaded via `transitobject.downloadrotatingbarcodevalues` for verification. If no valid barcodes are available, an error message is shown.\n"],null,["# Overview\n\nThe Google Wallet Passes API provides the ability for partners to save\n[Rotating\nBarcodes](/wallet/tickets/transit-passes/qr-code/resources/rotating-barcodes) to the Google Wallet. These barcodes are only valid for a short period of time,\nproviding additional security to reduce the risk of barcode screenshotting. The\nbarcodes are generated on device in accordance with\n[RFC 6238](https://www.rfc-editor.org/rfc/rfc6238), with the partner providing the\nsecret key. However, if a partner would rather generate the barcodes themselves, Google provides\nan API such that barcodes can be batch uploaded to Google. These barcodes will then\nbe passed through to users' phones, where they will act just like Rotating Barcodes,\ndisplaying for a short period of time. We refer to this solution as Partner-Generated\nRotating Barcodes.\n\nPartner-Generated Rotating Barcode API\n--------------------------------------\n\nPartner-Generated Rotating Barcodes are created using the same RotatingBarcode\nobject. Only the type is required, although we also recommend creating a small, starter\nset of barcodes (\\~10 minutes worth), and sending them in\n`initialRotatingBarcodeValues`. The partner is responsible for ensuring that there is\nalways a valid barcode ready for the user, and `initialRotatingBarcodeValues` allows\nthe subsequent batch upload call to be asynchronous. \n\n```gdscript\n rotatingBarcode {\n initialRotatingBarcodeValues: object (RotatingBarcodeValues),\n type: enum (BarcodeType),\n }\n```\n\n| Field | Description |\n|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `initialRotatingBarcodeValues` | `object (`[RotatingBarcodeValues](#RotatingBarcodeValues)`)` The values to encode in the barcode. At least one value is required. These initial barcodes are meant to bridge the gap between when the user first acquires their pass, and when the subsequent batch upload call is made. |\n| `type` | `enum (`[BarcodeType](/wallet/tickets/transit-passes/qr-code/rest/v1/BarcodeType)`)` Required. The type of this barcode. Acceptable values are: - `QR_CODE` - `PDF_417` \u003cbr /\u003e |\n\nRotatingBarcodeValues\n\n| Field | Description |\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `startDateTime` | `string` The date/time the first barcode is valid from. Barcodes will be rotated through using `periodMillis`. This is an ISO 8601 extended format date/time, with an offset. |\n| `values[]` | `string` The values to encode in the barcode. At least one value is required. There is no maximum number of values, but note that the size of the request body cannot exceed 5MB. |\n| `periodMillis` | `number` The amount of time each barcode is valid for. |\n\nBatch updating barcode values\n-----------------------------\n\nAfter the RotatingBarcode object has been created, we recommend uploading a day's\nworth of barcodes, every day, until the user's pass expires. This can be done with the\nfollowing REST API endpoint.\n\n### Method: transitobject.uploadrotatingbarcodevalues\n\nUploads rotating barcode values to the transit object referenced by the given object ID.\n\n#### HTTP request\n\n`POST\nhttps://walletobjects.googleapis.com/upload/walletobjects/v1/transitObject/{resourc\neId}/uploadRotatingBarcodeValues`\n\n#### Path parameters\n\n| Parameter | Description |\n|--------------|-----------------------------------------------|\n| `resourceId` | `string` The unique identifier for an object. |\n\n#### Request body\n\nThe request body (which cannot exceed 5MB) contains an instance of\n[RotatingBarcodeValues](#RotatingBarcodeValues).\n\n### Method: transitobject.downloadrotatingbarcodevalues\n\nDownloads rotating barcode values for the transit object referenced by the given object\nID. This is useful if partners want to verify the latest batch.\n\n#### HTTP request\n\n`GET\nhttps://walletobjects.googleapis.com/walletobjects/v1/transitObject/{resourceId}/do\nwnloadRotatingBarcodeValues?alt=media`\n\n#### Path parameters\n\n| Parameter | Description |\n|--------------|-----------------------------------------------|\n| `resourceId` | `string` The unique identifier for an object. |\n\nFallback mechanisms\n-------------------\n\nNote that if an otherwise-valid RotatingBarcode has no valid barcodes to display (they haven't been uploaded yet, or all the current barcodes have been used), an error message will be shown to the user."]]