When to call
CallattachFlowSource when executionState is initiated, source_attached, quoted, or signing. Attaching again before the payment is sent replaces the source, so the payer can change how they pay. Each attach issues a new session token, and the previous token stops working.
Attaching from signing requires the current session token, so it works only on the device that attached the source before. A flow in signing may already have a payment approved in the wallet.
Attaching needs no session token in the other states. That is how a payer on another device, or with cleared storage, resumes before the payment is sent. Read the flow with getFlow first and attach only when its state allows it.
Usage
Parameters
The parameters depend onsourceType. Payment sources explains each source.
Wallet source
The payer pays from a connected wallet. Dynamic screens the wallet address when it is attached.The SDK’s TypeScript type marks
fromChainId as optional for wallet sources, but the request fails without it. Always pass it.Exchange source
The payer pays from an exchange account, such as Coinbase, through a purchase link. Dynamic does not screen exchange sources.Deposit address source
The payer sends funds to an address generated for the payment, from any wallet or exchange. Dynamic does not screen deposit-address sources. Deposit addresses support EVM chains, Solana, Bitcoin, and TRON. The address arrives with the quote, so callgetFlowQuote next.
Do not pass
fromAddress with a deposit-address source; the request is rejected. Dynamic does not initiate refunds, and a refund can fail, as described in Failures and refunds.
Returns
Promise<FlowSourceResponse>:
Examples
Wallet on Solana
Exchange
Deposit address
Errors
Attaching from
signing without the current session token is rejected with error.code session_token_invalid. Show the flow as processing instead, because the payment may already have been approved. Handle Flow errors describes each error and how to recover.
React
useAttachFlowSource is a mutation hook. It takes the same parameters, and it writes the returned flow into the useGetFlow cache.
Related
- Build a custom payment UI: the wallet, deposit-address, and exchange paths end to end.
getFlowQuote: quote the attached source.getFlowSupportedExchanges: list the exchanges a flow supports.- Screening: which sources are screened and when.