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.
Import
Signature
Parameters
The
paymentId returned from createPayment / useNFCMerchant.The merchant’s wallet address (
merchantWallet from the payment response).Amount in micro-USDC (µUSDC). Multiply the USDC decimal amount by 1,000,000.
Unix timestamp in milliseconds when the invoice expires. Use
expiresAt from the createPayment response directly.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
- Signs the invoice payload with the merchant’s ECDSA private key (stored in Keychain)
- Serializes the signed payload as JSON
- Wraps it in an NDEF Text record
- Starts HCE emulation via
react-native-hce - Listens for the
HCE_STATE_READevent (customer tap) - 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.
