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

Constructor

new Deposit(config: DepositConfig)
Creates a new Deposit instance. Throws a DepositError with code INVALID_REQUEST if config.signer is missing or not a string/function.

DepositConfig

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 [BlinkDeposit] prefix.

Methods

requestDeposit

deposit.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 DepositError on failure. If a flow is already active, calling requestDeposit again cancels the previous flow and starts a new one. Throws DepositError with code INVALID_REQUEST if the instance has been destroyed. See Types for DepositRequest and DepositResult definitions.

on

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

off

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

close

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

destroy

deposit.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

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

Properties

status

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

result

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

error

deposit.error: DepositError | null
Last DepositError, available when status === 'error'.

isActive

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