executable: true. The widget handles the full purchase flow — including payment-method selection, verification, and transaction confirmation — inside an iframe.
Setup widget
Parameters
| Property | Type | Required | Description |
|---|---|---|---|
quote | string | ✅ | The quote signature returned from getQuote. |
container | HTMLElement | ✅ | A DOM element to render the widget frame into. |
onEvent | (event: WidgetEvent) => void | Callback invoked for widget flow events. See WidgetEvent. |
WidgetEvent
onEvent receives events as the widget flow progresses. Use event.kind to decide how to handle each event.
| kind | Payload | When you receive it |
|---|---|---|
"ready" | — | The widget is loaded and ready to be shown. |
"transactionCreated" | { transaction: { id: string; status: string } } | A transaction has been created. The customer may still need to complete additional steps (for example, 3-D Secure). |
"complete" | { transaction: FrameTransaction } | The widget flow finished. FrameTransaction is a discriminated union — handle the "failed" variant separately. |
"close" | — | The customer closed the widget. |
"error" | WidgetEventError | The flow encountered an error. |
FrameTransaction
The transaction reported by the widget on "complete". The shape depends on the outcome.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Present on the success variant. Required when status !== "failed"; optional when status is "failed". | |
status | string | ✅ | The transaction status. On the failure variant this is "failed". |
failureReason | string | Present only on the failure variant (status === "failed"). |
"complete", pass transaction.id to client.getTransaction().
WidgetEventError
| Field | Type | Required | Description |
|---|---|---|---|
code | "configurationError" | "apiError" | "generic" | ✅ | The error category. |
message | string | ✅ | Developer-friendly details. |
Result
client.setupWidget() returns a Result<WidgetFrame, SetupWidgetError>.
Result envelope
Result<WidgetFrame, SetupWidgetError>
| Field | Type | Required | Description |
|---|---|---|---|
ok | boolean | ✅ | Whether the operation succeeded. |
value | WidgetFrame | Present when ok is true. | |
error | SetupWidgetError | Present when ok is false. |
WidgetFrame
| Field | Type | Required | Description |
|---|---|---|---|
dispose | () => void | ✅ | Unmounts the frame. After you call this, no further events are dispatched to your onEvent callback. |
SetupWidgetError
| Field | Type | Required | Description |
|---|---|---|---|
kind | "configurationError" | "apiError" | "genericError" | ✅ | The error category. |
message | string | ✅ | Developer-friendly details. |
TS Definitions
TS Definitions
types.ts