@uphold/enterprise-payment-widget-web-sdk package.
The main class for creating and managing Payment Widget instances is PaymentWidget. It requires a PaymentWidgetSession object that must be created through the API before instantiating the Widget.
Constructor
Generic type parameter:
The constructor accepts an optional generic type parameter that specifies the flow type. When provided, it enables better type inference for event handlers, particularly for the
complete event.
Examples:
Options
paymentMethods option:
The
paymentMethods option allows you to control which payment methods the Widget displays to users. When not specified, all supported payment methods are available.
Basic usage:
bank and crypto payment methods, you can filter which assets are available using the assets property. This works the same way for both methods:
If no
assets filter is provided, all supported assets for that payment method will be available. Use either include or exclude, not both.theme option lets you control the visual appearance of the Widget. By default, the Widget automatically detects and matches the user’s browser or OS appearance preference (light or dark). Use this option when you want to enforce a specific theme regardless of the user’s system settings.
layout option controls how the Widget is laid out when there is enough room to frame it — on viewports that are both at least md wide (≥768px) and at least 600px tall, i.e. tablets and up. On smaller viewports — narrower or shorter, including phones in landscape — the Widget always fills its container regardless of this option.
'boxed'(default): on viewports that are ≥768px wide and ≥600px tall, centers the Widget and frames its content as a fixed-size card; on smaller viewports it fills its container. Use this when the Widget takes up the whole page (e.g. mounted into a full-page container).'fluid': renders the Widget so it fills its container, with no frame or centering, so your own container (e.g. a modal or a sized panel) acts as the frame.
'boxed' and only set layout: 'fluid' when embedding the Widget in your own framed container.
Use
'fluid' when you already provide a centered container or modal around the Widget, to avoid a card-within-a-card appearance on larger viewports.maxAccountsPerAsset option controls how many accounts can be created per asset. For example, setting it to 1 ensures only a single account exists per asset, while setting it to 5 allows up to five accounts for the same asset (e.g. one USD account for general use, another for a vacation fund, and so on). Once the limit is reached, the Widget automatically reuses the most recent account instead of creating a new one.
Values above
100 are capped at 100.Methods
mountIframe()
Mounts the Payment Widget iframe to the specified DOM element.
Parameters:
element: The HTML element where the Widget should be mounted
The container element should have explicit dimensions set via CSS. The Widget will fill the entire container. Minimum recommended size is 400px width × 600px height for optimal user experience.
unmount()
Unmounts and cleans up the Payment Widget iframe.
Example:
on()
Registers an event listener for Widget events.
Parameters:
event: The event name to listen forcallback: Function to execute when the event is triggered
off()
Removes an event listener for Payment Widget events.
Parameters:
event: The event name to stop listening forcallback: The specific function to remove (must be the same reference as used inon())
Events
The Payment Widget emits several events during its lifecycle that you can listen to using theon() method.
complete
Fired when the Payment flow is completed.
event.detail.value contains the payment flow result. The structure depends on the flow type.
Example:
select-for-deposit flows:
select-for-withdrawal flows:
authorize flows:
cancel
Fired when the user cancels the payment flow.
error
Fired when an unrecoverable error occurs during the payment flow.
ready
Fired when the Payment Widget has finished loading.
Types
PaymentWidgetSession
The session object returned by the Create session endpoint.PaymentWidgetFlow
Represents the different flows supported by the Payment Widget.
PaymentMethodOption
Defines the payment methods that can be configured in the Widget options.PaymentAssetOptions
Allows filtering which assets are available when using thebank or crypto payment methods.
Use either
include or exclude, not both. Asset codes should be uppercase (e.g., 'BTC', 'ETH', 'XRP').Complete event result types
DepositSelection
Result structure forselect-for-deposit flow:
For complete type definitions, see the API documentation:
ExternalAccount: External accountsAccountDepositMethod: Account deposit methodsAccount: Accounts
WithdrawalSelection
Result structure forselect-for-withdrawal flow:
For complete
ExternalAccount type definition, see the External accounts API documentation.AuthorizeResult
Result structure forauthorize flow:
For complete
Transaction type definition, see the Transactions API documentation.WidgetLayout
Controls how the Widget is laid out on larger viewports.WidgetThemeOption
Controls the visual appearance of the Widget.ColorTokenValue
A color value that can be a single string applied to both light and dark modes, or separate values per mode.FontFamily
A font family that can be a single string applied to all slots, or separate values per slot (mono, sans, serif).