Overview
Manages authentication and creates payout elements. The PayoutsSession handles token management, element creation, and provides convenience methods for showing elements in modals.Examples
Basic usage
Creating elements
Using modal methods
Options
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
token | string | Promise<string | null> | GetToken | null | Yes | - | The token to use for the session. If a function is provided, it will be called and awaited to get the token. When a function is provided, the token will be refreshed automatically before it expires. if a string is provided, it will be used as the token and not refreshed automatically. However you can update the token at runtime by calling ‘updateOptions’ with a new token. |
currency | string | undefined | No | ”USD” | The currency to use in the Elements |
companyId | string | Yes | - | The company ID to use in the Elements |
redirectUrl | string | Yes | - | URL to redirect to after identity verification is completed. This must be an absolute URL (e.g., “https://yourapp.com/callback”). Localhost URLs will not work - use ngrok for local development. |
Events
Events emitted by the PayoutsSession. Listen to these events using theon() method.
optionsUpdated
Emitted when the session options are updated via updateOptions().
Callback signature: (options: ExpandedPayoutsSessionOptions) => void
tokenRefreshed
Emitted when the authentication token is refreshed.
Callback signature: (token: string) => void
tokenRefreshError
Emitted when token refresh fails.
Callback signature: (error: unknown) => void
error
Emitted when an error occurs during session operation.
Callback signature: (error: unknown) => void
ready
Emitted when the session is ready and authenticated.
Callback signature: (void) => void
Methods
createElement(type, options)
Create a new element instance.
| Parameter | Type | Description |
|---|---|---|
type | T | { type: T; } | The element type (e.g., “balance-element”, “withdraw-button-element”) |
options | PayoutsSessionElements[T][0] | Element-specific configuration options |
PayoutsSessionElements[T][1]
updateOptions(options)
Update the session options after initialization.
Changes will be propagated to all active elements.
| Parameter | Type | Description |
|---|---|---|
options | Partial<PayoutsSessionOptions> | Partial options object with the values to update |
destroy()
Destroy the session and clean up all mounted elements.
Call this when you no longer need the session to free up resources.
Modal Methods
showWithdrawModal(options, force)
Show the withdraw element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | WithdrawElementOptions | ((modal: ModalContainer) => WithdrawElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showAddPayoutMethodModal(options, force)
Show the add payout method element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | AddPayoutMethodElementOptions | ((modal: ModalContainer) => AddPayoutMethodElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showAutomaticWithdrawModal(options, force)
Show the automatic withdraw settings element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | AutomaticWithdrawElementOptions | ((modal: ModalContainer) => AutomaticWithdrawElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showVerifyModal(options, force)
Show the identity verification element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | VerifyElementOptions | ((modal: ModalContainer) => VerifyElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showWithdrawalBreakdownModal(options, force)
Show the withdrawal breakdown element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | WithdrawalBreakdownElementOptions | ((modal: ModalContainer) => WithdrawalBreakdownElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showChangeAccountCountryModal(options, force)
Show the change account country element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | ChangeAccountCountryElementOptions | ((modal: ModalContainer) => ChangeAccountCountryElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showResetAccountModal(options, force)
Show the reset account element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | ResetAccountElementOptions | ((modal: ModalContainer) => ResetAccountElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showTotalBalanceBreakdownModal(options, force)
Show the total balance breakdown element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | TotalBalanceBreakdownElementOptions | ((modal: ModalContainer) => TotalBalanceBreakdownElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showRegularReserveBalanceBreakdownModal(options, force)
Show the regular reserve balance breakdown element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | RegularReserveBalanceBreakdownElementOptions | ((modal: ModalContainer) => RegularReserveBalanceBreakdownElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showBnplReserveBalanceBreakdownModal(options, force)
Show the BNPL reserve balance breakdown element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | BnplReserveBalanceBreakdownElementOptions | ((modal: ModalContainer) => BnplReserveBalanceBreakdownElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
showGenerateWithdrawalReceiptModal(options, force)
Show the generate withdrawal receipt element in a modal overlay.
| Parameter | Type | Description |
|---|---|---|
options | GenerateWithdrawalReceiptElementOptions | ((modal: ModalContainer) => GenerateWithdrawalReceiptElementOptions) | Element options or a callback that receives the modal container |
force | Force | undefined | - |
Force extends true ? ModalContainer : ModalContainer | undefined
