When to call
CallcancelFlow when executionState is source_attached, quoted, or signing. Cancelling needs the session token that attaching a source stores, so it works only on the device that attached the source.
- A flow in
initiatedhas no session token yet. Your server can cancel it with its API token, as described in the Flow payments API guide. - Nobody can cancel a flow once the payment is sent. Hide the cancel button as soon as the payer approves a wallet payment.
Usage
Parameters
Returns
Promise<Flow>: the flow with executionState: 'cancelled'.
Examples
Show the state when cancelling is too late
Errors
Handle Flow errors describes each error.
React
useCancelFlow is a mutation hook. It writes the cancelled flow into the useGetFlow cache, and on FlowStateConflictError it refetches the flow so the page shows its real state.
Related
- Expiry and cancellation: who can cancel and when.
- Build a custom payment UI: where the cancel button belongs.
getFlow: read the flow’s state.