Fireblocks Flow is an enterprise feature. Contact us to enable it for your environment.
FlowWidget is a prebuilt React component that runs the payer’s side of a Flow payment. You give it the ID of a flow your server created, and it loads the flow, lets the payer choose how to pay, runs the payment, and shows the result. It calls the same SDK functions described in Build a custom payment UI, so use that guide instead when you need screens the widget does not provide.
Prerequisites
@dynamic-labs-sdk/react-uiinstalled,flow.cssimported, and your app wrapped inDynamicUiProviderwith thedyn-flow-rootclass, as described in React UI components.- The chains your payers pay from enabled in the Dynamic Console and their chain extensions registered, as described in Get started with Flow payments. Wallet payments need them. Exchange and deposit-address payments do not.
- A server that creates the flow and passes
flow.idto the payer’s page, as described in Create a flow from your server.
Add the widget
RenderFlowWidget with the flow ID:
DynamicUiProvider next to the widget. If your app already has one at its root with the dyn-flow-root class, render FlowWidget on its own.
What the payer sees
The widget moves through these screens on its own:- Loading. The widget shows a loader while it reads the flow, and an error with a retry button when the flow cannot load.
- Payment method. The payer chooses to pay from a wallet, through an exchange, or by sending funds to a deposit address. When only one method is enabled, the widget skips this screen.
- The chosen method.
- Wallet. The payer connects a wallet, chooses the token to pay with, reviews the quote, and approves the transaction in the wallet. If they decline in the wallet, the widget lets them try again or choose another method.
- Exchange. The payer chooses an exchange, which opens in a new tab so they can buy the payment amount. The widget waits until the exchange confirms the purchase.
- Deposit address. The payer chooses the network and token to send and gives a refund address, and the widget shows the address and the exact amount to send. It then waits for the deposit.
- Processing. The widget shows the payment’s progress after the funds are sent.
- Outcome. The widget ends on payment complete, failed, refunded, cancelled, or expired, according to the flow’s state.
Handle the outcome
The widget calls one outcome callback with the latestFlow object:
Each callback fires at most once while the widget stays mounted. A new mount reports again: reloading the page or reopening the payment link for a finished flow calls the matching callback once more. Make your handlers idempotent by keying them on
flow.id.
Use the callbacks to update the payer’s page, such as to show your own confirmation or move to the next step. Decide whether to fulfill the order on your server, from webhooks or a server read of the flow, rather than from what the payer’s page reports. Access and data explains why.
Mount one widget per flow. Two widgets for the same flow each report the outcome, so your handlers run twice. Changing flowId on a mounted widget starts a new payment for the new flow.
Configure the widget
Passsettings to change what the widget shows. Each field you set replaces the matching value in the flow’s uiConfig, which your server can set when it creates the flow, as described in UI configuration. A field you leave out falls back to the flow’s value.
payerEvmAddress is an address your app already holds for the payer.
enabledPaymentMethods controls only what the widget shows. The API does not enforce it, so a payer can still attach another source with direct requests, and you should not rely on it for a compliance rule. Payment sources explains this further.
Offer one payment method
Each payment method is also available as its own widget, for a page that offers only that method or that builds its own method choice. They take the sameflowId, className, onPaymentCompleted, and onPaymentFailed props as FlowWidget, and they handle loading, processing, outcomes, and reloads the same way.
What the widget does not cover
Build these with the SDK, as described in Build a custom payment UI, when your payment page needs them:- Cancelling a flow. The widget has no cancel control. See Cancel.
- Changing the amount in
depositmode. The widget quotes the amount the flow was created with. See Deposit mode amount entry.
Change the text
Each Flow screen has its own slot in theDynamicUiProvider text dictionary, named after the screen, such as dyn-flow-choose-payment-source-view for the payment method choice. Text keys lists every Flow slot and key, grouped by screen, with its default.
Related
- React UI components: install the package and change its text and styles.
- Get started with Flow payments: set up chains and create a flow from your server.
- Build a custom payment UI: build every payment screen yourself.
- Payment lifecycle and states: what each flow state means.