UNPKG

@uphold/topper-web-sdk

Version:

Seamless integration of Topper on Web applications

89 lines (76 loc) 2.24 kB
declare enum Environments { PRODUCTION = "production", SANDBOX = "sandbox" } declare enum Events { ALL = "*", ORDER_CONTINUE_BUTTON_CLICKED = "orderContinueButtonClicked", ORDER_PLACED = "orderPlaced", ORDER_WALLET_SEND_BUTTON_CLICKED = "orderWalletSendButtonClicked", WIDGET_CONTINUE_BUTTON_CLICKED = "widgetContinueButtonClicked" } declare enum Flows { CRYPTO_OFFRAMP = "crypto_offramp", CRYPTO_ONRAMP = "crypto_onramp" } declare enum InitialScreens { AUTHENTICATION = "authentication" } declare enum Locales { EN = "en", EN_US = "en-US", PT = "pt", PT_BR = "pt-BR", ES = "es", ES_ES = "es-ES" } declare enum Themes { DARK = "dark", LIGHT = "light" } declare enum Urls { PRODUCTION = "https://app.topperpay.com", SANDBOX = "https://app.sandbox.topperpay.com", WEBSITE = "https://www.topperpay.com/" } declare enum Variants { IFRAME = "iframe", NEW_TAB = "new-tab", SAME_TAB = "same-tab" } interface Config { active_flow?: Flows | null; environment?: Environments; initial_screen?: InitialScreens | null; is_android_app?: boolean; is_ios_app?: boolean; locale?: Locales; theme?: Themes; variant?: Variants; } interface EventPayload { name?: string; data: any; } type EventHandler = (event: EventPayload) => void; declare class TopperWebSdk { private eventHandlers; private handleMessage; private isInitialized; private targetWindow; config: Config; constructor(config?: Config); static triggerEvent(eventName: Events, data?: any): void; private triggerEvent; private setConfig; private initializeMessageListener; dispose(): void; initialize({ bootstrapToken, bootstrapTokens, config, iframeElement }: { bootstrapToken?: string; bootstrapTokens?: string[]; iframeElement?: HTMLIFrameElement; config?: Config; }): void; on(eventName: Events, handler: EventHandler): void; } export { Environments as TOPPER_ENVIRONMENTS, Events as TOPPER_EVENTS, InitialScreens as TOPPER_INITIAL_SCREENS, Locales as TOPPER_LOCALES, Themes as TOPPER_THEMES, Urls as TOPPER_URLS, Variants as TOPPER_VARIANTS, TopperWebSdk };