useNFCMerchant manages the merchant side of the payment flow: calling the backend to create a payment request and providing state for the result.
Import
Usage
Return Value
(params) => Promise<PaymentRequest | null>
Creates a payment request on the TapRails backend. Returns a
PaymentRequest on success, or null if an error occurs (check the error state).boolean
true while the backend request is in-flight.boolean
true after a payment request has been successfully created.PaymentRequest | null
The most recently created payment request, or
null before any request is made.Error | null
Error from the most recent
createPaymentRequest call, or null on success.() => void
Clears all state — useful when starting a new payment flow.
createPaymentRequest params
string
required
Payment amount in USDC as a decimal string — e.g.,
"25.00". Do not pass a number.string
Merchant identifier. Falls back to
merchantId from ContactlessCryptoSDK.initialize() if omitted.Example
After
createPaymentRequest succeeds, call writeSignedInvoice to start NFC emulation (HCE). The hook itself does not initiate NFC — it only handles backend communication.
