UNPKG

@payos-inc/payos-wallet-onboard-js

Version:

PayOS Wallet Onboard JavaScript SDK for easy integration of the PayOS onboarding flow.

92 lines (91 loc) 2.25 kB
/** * PayOS Wallet Onboard JavaScript SDK * * This SDK provides client-side integration with PayOS Wallet Onboard, allowing * Developers to easily embed a secure card linking flow into their applications. */ export interface OnCloseData { success: boolean; walletUserId?: string; } export interface PayOSWalletOnboardOptions { /** * The container element or selector where the iframe will be mounted */ container: string | HTMLElement; /** * The token generated on the server side to authenticate with PayOS Link */ token: string; /** * Environment to use - 'sandbox' or 'production' */ environment?: "sandbox" | "production"; /** * The merchant name to display in the UI */ merchantName?: string; /** * Optional wallet user ID if already known */ walletUserId?: string; /** * Callback when the iframe is closed */ onClose?: (data: OnCloseData) => void; /** * Callback when an error occurs */ onError?: (error: Error) => void; /** * Optional height for the iframe */ height?: string; /** * Custom URL for the UI (for development or staging environments) * This overrides the environment setting */ customBaseUrl?: string; } /** * Main PayOS Wallet Onboard class */ declare class PayOSWalletOnboard { private container; private iframe; private options; private messageListener; /** * Create a new PayOS Wallet Onboard instance */ constructor(options: PayOSWalletOnboardOptions); /** * Mount the PayOS Wallet Onboard iframe to the container */ mount(): void; /** * Unmount the PayOS Wallet Onboard iframe */ unmount(): void; /** * Handle messages from the iframe */ private handleMessage; /** * Build the URL for the iframe */ private buildIframeUrl; /** * Get the base URL for the iframe based on environment */ private getBaseUrl; /** * Get allowed origins for postMessage security */ private getAllowedOrigins; /** * Validate the options provided */ private validateOptions; } export default PayOSWalletOnboard;