React Reference


useHandleInvoice is a hook that allows you to handle (accept) a single invoice. It returns an object with the following properties:

acceptInvoiceA function that accepts the invoice.
isLoadingBoolean indicating whether the invoice is being accepted.
errorThe error explaining why the last attempt to accept the invoice failed.
isAcceptedBoolean indicating whether the invoice has been accepted.
resetA function that resets the state of the hook (sets isAccepted to false and error to undefined).


This hook accepts two parameters:

invoice (required)The id of the invoice to handle (you can get it from the useInvoices hook).
options (optional)see below


onAccepted (optional)A function that will be called when the invoice is accepted. This is a good place to display a success message to the user.
onRejected (optional)A function that will be called when the invoice is rejected. This is a good place to display an error message to the user.
allocationTimeoutMs (optional)The timeout for the allocation in milliseconds. Defaults to 60 seconds.


function MyComponent({ id, status }) {
  const { acceptInvoice, isAccepted, isLoading } = useHandleInvoice(id, {
    onAccepted: () => {
      showToast(`Invoice accepted! 💸`, { type: 'success' })
    onRejected: () => {
      showToast(`There was an error accepting the invoice 😥`, {
        type: 'error',
  return (
        disabled={status !== InvoiceStatus.Received || isAccepted}
        {isLoading ? 'Accepting...' : isAccepted ? 'Accepted!' : 'Accept'}

Was this helpful?