complete when the pipeline
finishes.
Unlike other setup methods, setupChallenge() takes a url provided by the
upstream flow’s challenge event — or, for Identity API integrations, returned
by POST /platform/v1/identities/{id}/verifications. Pass it through as-is and
do not modify the URL yourself. If the URL doesn’t carry a channelId query
parameter, the SDK generates one automatically.
For more context, see the Handle
challenges guide.
Setup challenge
Parameters
| Property | Type | Required | Description |
|---|---|---|---|
url | string | ✅ | The URL from the upstream flow’s challenge event payload, or from an identity verification response. Pass it through unchanged. If the URL has no channelId query parameter, the SDK adds one. |
container | HTMLElement | ✅ | A DOM element to render the Challenge frame into. |
onEvent | (event: ChallengeEvent) => void | Callback invoked for Challenge flow events. See ChallengeEvent. |
ChallengeEvent
onEvent receives events as the challenge flow progresses. Use event.kind to
decide how to handle each event. The complete and cancelled payloads are
discriminated by payload.flow so you can branch on the originating flow.
| kind | Payload | When you receive it |
|---|---|---|
"ready" | — | The Challenge UI is rendered and visible to the customer. |
"complete" | ChallengeCompleteResult | All verification steps resolved. Discriminated by flow. |
"cancelled" | ChallengeCancellation | The customer dismissed the challenge. Discriminated by flow. Offer a retry path or exit. |
"error" | ChallengeEventError | The challenge failed with a terminal error. |
ChallengeCompleteResult
The complete payload is discriminated by flow:
| Field | Type | Required | Description |
|---|---|---|---|
flow | "buy" | "identity" | ✅ | Identifies which upstream flow the challenge resolved. |
transaction | Transaction | Present when flow is "buy". The created or updated transaction. | |
identityId | string | Present when flow is "identity". The identity record that was verified. |
ChallengeCancellation
The cancelled payload is discriminated by flow:
| Field | Type | Required | Description |
|---|---|---|---|
flow | "buy" | "identity" | ✅ | Identifies which upstream flow was cancelled. |
transactionId | string | Present when flow is "buy". The transaction associated with the cancelled challenge. | |
challengeToken | string | Present when flow is "buy". The challenge token from the original challenge event. |
Transaction
This is the transaction object returned when the buy challenge completes. It uses the same FrameTransaction shape as setupBuy().
| Field | Type | Required | Description |
|---|---|---|---|
status | string | ✅ | The transaction status. On the failure variant, "failed". |
id | string | Required on the non-failure variant; optional when status is "failed". | |
failureReason | string | Present only on the failure variant (status === "failed"). |
ChallengeEventError
| Field | Type | Required | Description |
|---|---|---|---|
code | string | ✅ | A machine-readable error category propagated from the challenge frame. Surface to logs, not UI. |
message | string | ✅ | Developer-friendly details. |
Result
client.setupChallenge() returns a Result<ChallengeFrame, SetupChallengeError>.
Result envelope
Result<ChallengeFrame, SetupChallengeError>
| Field | Type | Required | Description |
|---|---|---|---|
ok | boolean | ✅ | Whether the operation succeeded. |
value | ChallengeFrame | Present when ok is true. | |
error | SetupChallengeError | Present when ok is false. |
ChallengeFrame
| Field | Type | Required | Description |
|---|---|---|---|
dispose | () => void | ✅ | Unmounts the frame. After you call this, no further events are dispatched to your onEvent callback. |
setupBuy(), setupApplePay(), and setupGooglePay(), the
ChallengeFrame does not expose a setQuote() method. The challenge frame
runs to completion on its own.
SetupChallengeError
| Field | Type | Required | Description |
|---|---|---|---|
kind | "configurationError" | "genericError" | ✅ | The error category. |
message | string | ✅ | Developer-friendly details. |
TS Definitions
TS Definitions
types.ts