概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Google Wallet Passs API,合作伙伴可轻松保存
旋转
条形码发送到 Google 钱包。这些条形码仅在短期内有效
提供额外的安全保障,以降低条形码截屏的风险。通过
设备上按照
RFC 6238(由提供
密钥。不过,如果合作伙伴更希望自行生成条形码,
以便将条形码批量上传到 Google。然后,这些条形码
传递给用户的而这些手机的操作方式就像旋转条形码一样,
显示一小段时间。我们将该解决方案称为“合作伙伴生成”
轮换条形码。
合作伙伴生成的旋转条形码 API
合作伙伴生成的旋转条形码使用相同的旋转条形码创建
对象。只有类型是必填项,不过我们还建议创建一个小型的启动方式
一组条形码(大约 10 分钟),
initialRotatingBarcodeValues
。合作伙伴有责任确保
始终向用户提供有效的条形码,initialRotatingBarcodeValues
则允许
因此后续批量上传调用设为异步执行
rotatingBarcode {
initialRotatingBarcodeValues: object (RotatingBarcodeValues),
type: enum (BarcodeType),
}
字段 |
说明 |
initialRotatingBarcodeValues |
object (RotatingBarcodeValues)
要在条形码中编码的值。必须至少提供一个值。这些初始
条形码的作用是消除用户首次获得卡券与
在进行后续批量上传调用时触发。
|
type |
enum (BarcodeType)
必需。此条形码的类型。
可接受的值包括:
|
RotatingBarcodeValues
字段 |
说明 |
startDateTime |
string
第一个条形码的有效日期/时间。条形码将通过
使用 periodMillis 。
这是 ISO 8601 扩展格式的日期/时间,带偏移量。
|
values[] |
string
要在条形码中编码的值。必须至少提供一个值。
值没有上限,但请注意,请求正文的大小
不能超过 5MB。
|
periodMillis |
number
每个条形码的有效期。
|
批量更新条形码值
创建 RotatingBarcode 对象后,我们建议您上传
直至用户卡券过期。为此,您可以使用
以下 REST API 端点。
方法:transitobject.uploadrotatingbarcodevalues
将轮播的条形码值上传到指定对象 ID 引用的公交对象。
HTTP 请求
POST
https://walletobjects.googleapis.com/upload/walletobjects/v1/transitObject/{resourc
eId}/uploadRotatingBarcodeValues
路径参数
参数 |
说明 |
resourceId |
string
对象的唯一标识符。
|
请求正文
请求正文(不得超过 5MB)包含
RotatingBarcodeValues。
方法:transitobject.downloadrotatingbarcodevalues
下载指定对象引用的公交对象的轮替条形码值
ID。如果合作伙伴想要验证最新批次,这将非常有用。
HTTP 请求
GET
https://walletobjects.googleapis.com/walletobjects/v1/transitObject/{resourceId}/do
wnloadRotatingBarcodeValues?alt=media
路径参数
参数 |
说明 |
resourceId |
string
对象的唯一标识符。
|
回退机制
请注意,如果其他有效的 RotatingBarcode 没有可显示的有效条形码(
尚未上传,或当前的所有条形码都已用完),则会发生错误
相应消息会向用户显示
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\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."]]