Skip to main content
The Checkout class is the main entry point for the SDK. It manages the signer call, iframe lifecycle, and completion handling.
import { Checkout } from '@swype-org/checkout';

Constructor

new Checkout(config: CheckoutConfig)
Creates a new Checkout instance. Throws a CheckoutError with code INVALID_REQUEST if config.signer is missing or not a string/function.

CheckoutConfig

PropertyTypeDefaultDescription
signerstring | SignerFunctionrequiredURL string for the signer endpoint, or a custom async function. When a string, the SDK sends a POST with a JSON SignerRequest body. When a function, the SDK calls it with a SignerRequest and expects a Promise<SignerResponse>.
webviewBaseUrlstring'https://pay.tryblink.xyz'Base URL of the hosted payment webview app. The SDK appends merchantId, payload, and signature as query parameters.
hostedFlowOriginstringDerived from webviewBaseUrlOrigin for postMessage validation.
containerElementHTMLElementdocument.bodyDOM element to mount the iframe overlay into.
signerTimeoutMsnumber15000Maximum milliseconds to wait for the signer to respond.
flowTimeoutMsnumberundefined (no limit)Maximum milliseconds for the entire flow (signer + user completion).
debugbooleanfalseLog lifecycle events to console.debug with the [BlinkCheckout] prefix.

Methods

requestDeposit

checkout.requestDeposit(request: DepositRequest): Promise<DepositResult>
Opens the hosted payment flow for the given deposit. The returned Promise resolves when the user completes the payment and rejects with a CheckoutError on failure. If a flow is already active, calling requestDeposit again cancels the previous flow and starts a new one. Throws CheckoutError with code INVALID_REQUEST if the instance has been destroyed. See Types for DepositRequest and DepositResult definitions.

on

checkout.on(event: EventName, handler: EventHandler): this
Register an event listener. Returns this for chaining. See Events.

off

checkout.off(event: EventName, handler: EventHandler): this
Remove a previously registered event listener. Returns this for chaining.

close

checkout.close(): void
Close the checkout iframe without waiting for completion. Resets status to idle and fires the close event.

destroy

checkout.destroy(): void
Tear down the instance and release all resources. Closes the iframe, removes all event listeners, and marks the instance as destroyed. Subsequent calls to requestDeposit will reject with INVALID_REQUEST. Call this on component unmount or page unload.

focus

checkout.focus(): void
No-op. Retained for API compatibility.

Properties

status

checkout.status: CheckoutStatus
Current phase of the checkout flow. One of 'idle', 'signer-loading', 'iframe-active', 'completed', or 'error'.

result

checkout.result: DepositResult | null
Last successful DepositResult, available when status === 'completed'.

error

checkout.error: CheckoutError | null
Last CheckoutError, available when status === 'error'.

isActive

checkout.isActive: boolean
true when a deposit flow is in progress (status is 'signer-loading' or 'iframe-active').