Skip to main content
usePaymentStatus polls the TapRails backend for payment confirmation. Use this after initiating a payment to know when it’s been confirmed on-chain.

Import

Usage

Options

string
The payment ID to poll. Can also be passed to startPolling() instead.
number
Interval between status checks in milliseconds. Default: 2000 (2 seconds).
boolean
If true, polling starts immediately on mount using the provided paymentId. Default: false.

Return Value

(paymentId?: string) => void
Starts polling. Optionally accepts a paymentId to override the one from options.
() => void
Stops the polling interval.
(paymentId: string) => Promise<PaymentStatusResponse>
One-shot status fetch without starting continuous polling.
boolean
true while the polling interval is active.
PaymentStatusResponse | null
The latest status response from the backend.
boolean
true when status.status === 'confirmed'.
boolean
true when status.status === 'failed'.
string | undefined
On-chain transaction hash once confirmed.
number | undefined
Unix timestamp (ms) of confirmation.
APIError | null
Error from the most recent poll.
() => void
Clears the error state.
() => void
Stops polling and clears all state.

Example