錯誤代碼和例外狀況
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
API 錯誤回應
下表說明 Google Wallet API 可能會傳回的錯誤代碼、可能的原因以及解決方法。
例外狀況 |
訊息範例 |
建議 |
400 - BadRequestException |
要求含有無效引數,資源 ID 無效:{1234567891234567899 - ABCD1234567}。 |
檢查類型、格式和長度的資料結構,並傳遞正確的引數。 |
403 - PermissionDeniedException |
權限遭拒 |
確認正確的服務帳戶電子郵件是商家付款和錢包主控台的授權使用者。 |
404 - NotFoundException |
找不到錢包物件 {1234567891234567899.SampleClubCardxf6a8edf-87ca-4022-a813-694cc57e9fd3}。 |
嘗試提出 PATCH 或 PUT 要求之前,請先對物件 ID 執行 GET,確保您有需要更新的物件且是最新版本。 |
404 - IssuerClassNotFoundException |
找不到錢包物件類別 {1234567891234567899.ABCD.1234567}。 |
執行更新時,請務必在 PATCH 或 PUT 要求之前執行 GET 要求,確保您的類別可以參照其是最新的類別。此外,也請確認要求中使用的酬載 (物件和類別) 正確無誤。 |
409 - OnceExistsException |
已有電子錢包物件類別 {1234567891234567899.ABCD.1234567}。 |
請先對類別 ID 執行 GET,再嘗試建立相同的課程 ID。如果該資源存在,建議您使用 PATCH 或 PUT.。 |
網頁式錯誤訊息
如果您嘗試使用「新增至 Google 錢包」連結儲存票證時發生錯誤,系統會顯示資訊豐富的錯誤訊息,協助您進行偵錯。使用者必須具備相關聯核發者帳戶的「開發人員」或「管理員」角色,才會看到這類訊息。
以下是可能會出現的錯誤訊息類型範例:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eThis page explains the different error codes that may be returned by the Google Wallet API, including BadRequestException, PermissionDeniedException, NotFoundException, IssuerClassNotFoundException, and AlreadyExistsException.\u003c/p\u003e\n"],["\u003cp\u003eEach error code has an explanation for the possible causes and suggestions for troubleshooting and resolving the issue.\u003c/p\u003e\n"],["\u003cp\u003eFor web-based errors, when attempting to save a pass using 'Add to Google Wallet,' informative messages will be displayed to users with 'Developer' or 'Admin' roles for debugging purposes.\u003c/p\u003e\n"]]],["The Google Wallet API returns specific error codes: 400 (BadRequestException) indicates an invalid argument, requiring checks on data structure. 403 (PermissionDeniedException) means the service account lacks authorization. 404 (NotFoundException) signals a missing Wallet Object or Class, needing a GET request before PATCH/PUT actions. 409 (AlreadyExistsException) indicates an existing class, suggesting a GET request and potential PATCH/PUT instead of creating it again. Web errors are displayed to developers and admins.\n"],null,["# Error codes and exceptions\n\nAPI error responses\n-------------------\n\nThe following table explains error codes that mayn be returned by the Google Wallet API, their possible causes, and solutions.\n\n| Exception | Example Message | Suggestion |\n|------------------------------------|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 400 - BadRequestException | Request contains an invalid argument. Invalid resource ID: {1234567891234567899 - ABCD1234567}. | Check the data structure for type, format and length and pass the correct argument. |\n| 403 - PermissionDeniedException | Permission Denied | Ensure the correct [Service Account](https://developers.google.com/wallet/retail/loyalty-cards/web/prerequisites#4.-authorize-the-service-account) email is an authorized user within your Business Pay and Wallet Console. |\n| 404 - NotFoundException | Wallet Object {1234567891234567899.SampleClubCardxf6a8edf-87ca-4022-a813-694cc57e9fd3} not found. | Perform a [GET](https://developers.google.com/wallet/generic/rest/v1/genericclass/get#http-request) on the Object ID before trying before a [PATCH](https://developers.google.com/wallet/generic/rest/v1/genericclass/patch#http-request) or [PUT](https://developers.google.com/wallet/generic/rest/v1/genericclass/update#http-request) request to ensure you have an object to update and that it's the latest. |\n| 404 - IssuerClassNotFoundException | Wallet Object Class {1234567891234567899.ABCD.1234567} not found. | When performing an update , ensure you do a [GET](https://developers.google.com/wallet/generic/rest/v1/genericclass/get#http-request) request before a [PATCH](https://developers.google.com/wallet/generic/rest/v1/genericclass/patch#http-request) or [PUT](https://developers.google.com/wallet/generic/rest/v1/genericclass/update#http-request) request to ensure you have a class to reference that it's the latest class. Also ensure the correct payload (object and class) is being used in the request correctly. |\n| 409 - AlreadyExistsException | Wallet Object Class {1234567891234567899.ABCD.1234567} already exists. | Perform a [GET](https://developers.google.com/wallet/generic/rest/v1/genericclass/get#http-request) on the Class ID before trying to create the same Class ID. If the resource exists you may want to use [PATCH](https://developers.google.com/wallet/generic/rest/v1/genericclass/patch#http-request) or [PUT.](https://developers.google.com/wallet/generic/rest/v1/genericclass/update#http-request) |\n\nWeb-based error messages\n------------------------\n\nIf something goes wrong when you attempt to save a pass using an 'Add to Google Wallet' link, you will be shown an informative error message to help you debug. These messages are only shown to users that have the 'Developer' or 'Admin' role for the associated Issuer account.\n\nHere is an example of the type of error message that might be displayed:"]]