Skip to main content
writeSignedInvoice enables the Android HCE layer to emit a signed payment invoice over NFC. When a customer taps their phone to the merchant device, the invoice is read by the customer’s app.
This function requires an Android device with HCE support. It will not work on iOS.

Import

Signature

Parameters

string
required
The paymentId returned from createPayment / useNFCMerchant.
string
required
The merchant’s wallet address (merchantWallet from the payment response).
number
required
Amount in micro-USDC (µUSDC). Multiply the USDC decimal amount by 1,000,000.
number
required
Unix timestamp in milliseconds when the invoice expires. Use expiresAt from the createPayment response directly.
(value: boolean) => void
required
Callback invoked with true when the customer’s device successfully reads the NFC tag. Use this to transition to a “processing” state on the merchant screen.

What it does internally

  1. Signs the invoice payload with the merchant’s ECDSA private key (stored in Keychain)
  2. Serializes the signed payload as JSON
  3. Wraps it in an NDEF Text record
  4. Starts HCE emulation via react-native-hce
  5. Listens for the HCE_STATE_READ event (customer tap)
  6. On read: invokes setHasExchangedData(true), then cancels the session after 1.5s

Example

writeSignedInvoice returns as soon as HCE emulation starts — it does not block until the customer taps. The setHasExchangedData callback fires asynchronously when the tap occurs.