Skip to main content
useNFCCustomer manages the customer side of the payment flow: scanning an NFC tag from a merchant device and processing the payment via the TapRails backend.

Import

Usage

Return Value

() => Promise<PaymentRequest | null>
Activates the NFC reader and waits for a merchant’s tag. Validates the ECDSA signature, expiry, and timestamp window before returning. Returns null on failure (check error).
(paymentId, txHash, customerWallet?) => Promise<ProcessPaymentResponse | null>
Submits the scanned payment to the TapRails backend for execution. Returns null on failure.
boolean
true while the NFC reader is open and waiting for a tag.
boolean
Alias for isReading.
boolean
true while the backend payment request is in-flight.
PaymentRequest | null
The payment request read from the NFC tag, or null before a scan.
ProcessPaymentResponse | null
The result of processing the payment, or null before processing.
NFCPaymentError | Error | null
Error from the most recent scan or process call.
() => void
Clears paymentRequest, processedPayment, and error — resets the hook to idle.
() => void
Clears only the error state.

processPaymentRequest params

string
required
The paymentId from the scanned PaymentRequest.
string
required
Transaction hash. Pass an empty string "" for POOL mode (the backend provides the hash). Required for SESSION_KEY mode.
string
The customer’s wallet address. Required only in SESSION_KEY mode.

Example