NFCPaymentError for NFC-layer failures and APIError for backend communication failures. Both extend Error with a typed code for programmatic handling.
NFCPaymentError
Thrown bywriteSignedInvoice, readSignedInvoice, and the useNFCMerchant / useNFCCustomer hooks.
Handling NFC errors
APIError
Thrown by the API client layer (createPayment, processPayment, etc.) and surfaced via usePayment, usePaymentStatus, and related hooks.
Handling API errors
Retry Behaviour
The SDK’s API client automatically retries server errors (5xx) and network timeouts with exponential backoff:| Attempt | Delay |
|---|---|
| 1st retry | 1 second |
| 2nd retry | 2 seconds |
| 3rd retry (final) | — throws error |
Error States in Hooks
All hooks expose anerror property and a clearError (or reset) method. Prefer handling errors via state rather than try/catch at the call site:
Common Issues
| Symptom | Likely cause | Fix |
|---|---|---|
NFCErrorCode.NOT_SUPPORTED | Simulator or non-NFC device | Test on a physical device with NFC |
NFCErrorCode.TIMEOUT | Device too far from terminal | Hold devices back-to-back and ensure HCE is active |
NFCErrorCode.INVALID_DATA + “expired” | Invoice older than 5 minutes | Have merchant create a new payment request |
NFCErrorCode.INVALID_DATA + “signature” | Merchant device not registered | Call device registration before emitting HCE |
APIErrorCode.UNAUTHORIZED (401) | Wrong or missing API key | Verify apiKey in initialize() |
APIErrorCode.SDK_NOT_INITIALIZED | Hook used before initialize() | Move initialize() to app entry, before rendering |

