兑换通用卡券
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
卡券可通过以下两种方式兑换:
您可以选择在用户兑换或访问卡券时要求采取额外的安全措施。如需了解详情,请参阅使用屏幕锁定功能提供保护。
NFC 触碰
您的用户可通过 NFC 触碰无缝兑换卡。详细了解智能触碰,并注册使用智能触碰功能。
条形码扫描
通过附加条形码帮助客户扫描卡券。
静态条形码
您可以通过设置 object.barcode
来显示静态条形码。此 API 提供了各种类型的条形码。如需了解详情,请参阅 Barcode
类型。
轮换条形码
为提高安全性,您可以通过设置 object.rotatingBarcode
显示轮替条形码。旋转的条形码看起来和常规条形码一样,但定期更改,通常是每分钟更改,并且终端/读取器已编程为仅接受最新的条形码。这样可以降低与条形码屏幕截图(尤其是门票被盗或未经授权的门票转销)相关的风险。如需了解详情,请参阅 RotatingBarcode
类型。
安全动画
防止滥用屏幕截图的另一种方法是显示条形码安全动画,该动画支持对卡券进行人工验证。
安全动画的实际表现形式是卡券条形码周围的闪烁轮廓。这种闪烁动画仅在设备处于运动状态时触发,因此用户可以通过倾斜设备来测试卡券的有效性。另一方面,如果让设备保持静止不动,系统仅会以动画形式循环播放彩色安全动画。
如需为卡券启用安全动画,请在卡券类中将 SecurityAnimation
字段的 AnimationType
设置为 FOIL_SHIMMER
。
请参见下面的图 1,查看启用安全动画后如何显示安全动画的示例:
图 1.
使用屏幕锁定功能提供保护
为了保护客户对卡券的访问权限,您可以要求客户在每次添加或访问卡券时设置屏幕锁定。可以通过设置 class.viewUnlockRequirement
来完成此操作。如需了解详情,请参阅 ViewUnlockRequirement
类型。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003ePasses can be redeemed by customers using either NFC tap or barcode scan.\u003c/p\u003e\n"],["\u003cp\u003eRotating barcodes and security animations enhance security by mitigating risks like ticket theft and unauthorized resale.\u003c/p\u003e\n"],["\u003cp\u003ePasses can be further protected by requiring a screen lock for access, using the \u003ccode\u003eclass.viewUnlockRequirement\u003c/code\u003e setting.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can find detailed information about various features and settings through the provided links to the Google Pay API documentation.\u003c/p\u003e\n"],["\u003cp\u003eSmart Tap enables seamless redemption and merchants can sign up for it through the provided support link.\u003c/p\u003e\n"]]],["Passes can be redeemed via NFC tap or barcode scan. Barcodes can be static or rotating for enhanced security, changing periodically to prevent unauthorized use. Another security measure, the security animation, displays a shimmering outline around the barcode that triggers upon device motion. Additional security can be set via screen lock to control access to the pass. To set the barcode, use object.barcode or object.rotatingBarcode and for security animation use class.viewUnlockRequirement.\n"],null,["# Redeem a Generic pass\n\nPasses can be redeemed in either of two ways:\n\n- [NFC tap](#use-nfc-tap)\n- [Barcode scan](#use-barcode-scan)\n\nYou can optionally require extra security when users redeem or access their pass. For details,\nsee [Protect with Screen Lock](#protect-with-screen-lock).\n\nNFC tap\n-------\n\nYour users can seamlessly redeem their cards using an NFC tap. Learn more about\n[Smart Tap](/wallet/smart-tap), and\n[sign up](https://support.google.com/pay/merchants/contact/smart_tap_support) for Smart\nTap.\n\nBarcode scan\n------------\n\nHelp your customers scan their Pass by attaching a barcode.\n\n### Static barcode\n\nYou can display a static barcode by setting `object.barcode`.\nThe API provides a variety of barcode types. For more details, see the\n[`Barcode` type](/wallet/generic/rest/v1/Barcode).\n\n### Rotating barcode\n\n\nFor additional security, you can display a rotating barcode by setting\n`object.rotatingBarcode`. Rotating barcodes look just like regular barcodes but\nchange periodically, typically every minute, and the terminal/reader is programmed to only\naccept the most recent one. This reduces the risks associated with barcode screenshotting, in\nparticular ticket theft or unauthorized ticket resale. For more details, see the\n[`RotatingBarcode` type](/wallet/generic/rest/v1/RotatingBarcode).\n\n### Security animation\n\n\nAnother way to prevent screenshot abuse is by displaying the barcode security animation, which\nsupports human-verification of a pass.\n\n\nThe physical manifestation of a security animation is a shimmering outline around the barcode of\nthe pass. This shimmering animation triggers only when the device is in motion so one can test\nthe pass' validity by tilting the device. On the other hand holding the device still will only\nanimate the colorful security animation in loop.\n\n\nTo enable security animation for a pass, in the pass class, set the [`SecurityAnimation`](/wallet/generic/rest/v1/SecurityAnimation)\nfield's [`AnimationType`](/wallet/generic/rest/v1/SecurityAnimation#AnimationType)\nto `FOIL_SHIMMER`.\n\n\nSee Figure 1. below for an example of how the security animation appears when it is enabled:\n\n\n**Figure 1.**\n\nProtect with Screen Lock\n------------------------\n\nTo protect your customer's access to their Pass, you can require a screen\nlock each time they add or access their pass. This can be done by setting `class.viewUnlockRequirement`.\nFor more details, see the\n[`ViewUnlockRequirement` type](/wallet/generic/rest/v1/ViewUnlockRequirement)."]]