Use this file to discover all available pages before exploring further.
The Payment Widget handles card linking and selection for deposits via the Select for Deposit flow, where users can add a new card or pick an existing one directly in the widget. After the user confirms a card deposit quote, the Payment Widget creates the transaction and handles any 3DS challenge the issuer requires via the Authorize flow.
The complete event fires after the user selects a card. The event payload includes the selected card external account.
widget.on('complete', (event) => { const { via, selection } = event.detail.value; if (via === 'external-account') { // selection is the selected card external account // use selection.id as the origin in the quote handleCardSelected(selection); } widget.unmount();});
Once you have the selected card, prompt the user to select a destination account, then create a quote.
The error event fires for critical unrecoverable errors. Card-specific errors (duplicate card, country mismatch, card limits) are handled by the widget internally.
widget.on('error', (event) => { console.error('Widget error:', event.detail.error); widget.unmount(); // Show a user-friendly error message});
The Payment Widget handles most errors internally. For unrecoverable errors, the widget fires an error event. It is the host application’s responsibility to handle these events, present an error message to the user, and unmount the widget.
Card deposits can target any account. If the selected account is not in the card’s currency, the amount will be converted at settlement using Uphold’s prevailing rate. Make sure the destination asset has the necessary features enabled.
After the user confirms the card deposit quote, hand off to the Payment Widget Authorize flow. This flow creates the transaction, completes any 3DS challenge the issuer requires, and polls until a terminal status is reached — so the same flow works whether or not authorization is needed.
The error event fires for critical unrecoverable errors. Card-specific errors (duplicate card, country mismatch, card limits) are handled by the widget internally.
The operation is not permitted (e.g. duplicate withdrawal, card unauthorized)
user_capability_failure
The user lacks the required capability for this operation
The Payment Widget handles most errors internally. For unrecoverable errors, the widget fires an error event. It is the host application’s responsibility to handle these events, present an error message to the user, and unmount the widget.
import { PaymentWidget } from '@uphold/enterprise-payment-widget-web-sdk';const initializeAuthorizeWidget = async (session) => { const widget = new PaymentWidget<'authorize'>(session, { debug: true }); widget.on('complete', (event) => { const { transaction, trigger } = event.detail.value; handleAuthorizeComplete(transaction, trigger); widget.unmount(); }); widget.on('cancel', () => { widget.unmount(); // Return the user to the previous screen }); widget.on('error', (event) => { const { code, details } = event.detail.error; handleAuthorizeError(code, details); widget.unmount(); }); widget.mountIframe(document.getElementById('payment-container'));};const handleAuthorizeComplete = (transaction, trigger) => { if (trigger.reason === 'transaction-status-changed') { if (transaction.status === 'completed') { // Show success — transaction is settled } else if (transaction.status === 'failed') { handleTransactionFailure(transaction.statusDetails.reason); } } else if (trigger.reason === 'max-retries-reached') { // Widget stopped polling — continue monitoring via webhooks or polling }};const handleTransactionFailure = (reason) => { switch (reason) { case 'card-declined-by-bank': case 'card-permanently-declined-by-bank': // Prompt the user to try a different card break; case 'card-expired': // Prompt the user to update their card break; case 'card-unauthorized': // 3DS authentication was not completed break; case 'card-unsupported': // Card type is not supported for this operation break; case 'insufficient-funds': // User does not have enough funds break; case 'provider-maximum-limit-exceeded': case 'velocity': // Transaction blocked by limits — inform the user break; default: // Unhandled reason — show a generic error message break; }};const handleAuthorizeError = (code, details) => { switch (code) { case 'entity_not_found': // Quote expired — prompt user to start over break; case 'insufficient_balance': // Origin account has insufficient balance break; case 'operation_not_allowed': // Operation not permitted (e.g. duplicate withdrawal, card unauthorized) break; case 'user_capability_failure': // User lacks the required capability break; default: // Unexpected error — show a generic error message break; }};
In a successful card deposit, the origin is the external-account representing the card and the destination is the user’s account.