概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Google Wallet Passes API,合作伙伴可以将旋转条形码保存到 Google 钱包。这些条形码仅在短期内有效,降低了利用屏幕截图进行欺诈的风险,从而增强了安全性。条形码会根据 RFC 6238 在设备上生成,合作伙伴提供密钥。不过,如果合作伙伴更愿意自行生成条形码,Google 提供了一个 API,以便将条形码批量上传到 Google。然后,这些条形码会传递到用户的手机上,在那里,它们的运作方式与旋转条形码一样,会显示一小段时间。我们将此解决方案称为“合作伙伴生成的旋转条形码”。
合作伙伴生成的旋转条形码 API
合作伙伴生成的旋转条形码是使用相同的 RotatingBarcode 对象创建的。只有类型是必需的,但我们还建议您创建一组小型入门条形码(大约 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):2024-11-30。
[[["易于理解","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):2024-11-30。"],[[["Google Wallet now supports Partner-Generated Rotating Barcodes for enhanced security, allowing partners to generate and upload time-limited barcodes directly."],["Partners can integrate Rotating Barcodes using the `rotatingBarcode` object within the Google Wallet Passes API, specifying the barcode type and initial values."],["The API provides methods for batch uploading (`transitobject.uploadrotatingbarcodevalues`) and downloading (`transitobject.downloadrotatingbarcodevalues`) barcode values for ongoing updates."],["To ensure continuous barcode availability, it is recommended to upload a day's worth of barcodes daily until a user's pass expires, utilizing the `initialRotatingBarcodeValues` for a smooth initial experience."],["If a Rotating Barcode lacks valid values, an error message will be displayed to the user, highlighting the importance of timely barcode updates."]]],["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"]]