Subscribe for Payment Result
The onResult method registers a callback that is invoked whenever a checkout flow completes, whether the payment succeeded, failed, or was cancelled. This includes results that arrive after a 3DS redirect.Usage#
API Reference#
embedded.checkout.onResult(callback)#
| Parameter | Type | Required | Description |
|---|
| callback | (result: CheckoutResult) => void | Yes | Called when a checkout completes. |
Return Value#
| Type | Description |
|---|
function | An unsubscribe function to remove the listener. |
CheckoutResult#
| Property | Type | Description |
|---|
| success | boolean | true if the payment was completed successfully. |
| order_id | string | undefined | The order ID, present on successful payment. |
| status | string | Payment status: "paid", "pending", "failed", "cancelled", or "success". |
| error | object | undefined | Error details with code and message properties. |
| context | unknown | undefined | The context object passed to create(), restored after 3DS redirect. |
3DS Redirect Recovery#
When a payment requires 3DS verification, the merchant is redirected away from the dashboard and back. The SDK handles this automatically:1.
Before redirect, the host stores the pending checkout state (including your context).
2.
After redirect, the iframe reloads and the SDK delivers the stored result to your onResult callback.
3.
The context you passed to create() is preserved and returned in the result.
Register Early: Set up onResult during your app's initialization, before any create() calls, to catch results from 3DS redirects that occurred in a previous session.
Clean Up: Call the unsubscribe function when your component unmounts to prevent memory leaks.
Handle All States: Always handle both success: true and success: false cases to provide clear feedback to the merchant.
Modified at 2026-02-11 20:23:15