UNPKG

dodopayments-checkout

Version:

A TypeScript library for embedding Dodo Payments overlay checkout.

43 lines (42 loc) 1.36 kB
/** * SDK Type Definitions */ export type CheckoutMode = "test" | "live"; export type DisplayType = "overlay"; export type LinkType = "static" | "dynamic"; export type ThemeType = "light" | "dark"; export type EventType = "checkout.opened" | "checkout.payment_page_opened" | "checkout.closed" | "checkout.error" | "checkout.customer_details_submitted" | "checkout.redirect"; export interface CheckoutEvent { event_type: EventType; data?: Record<string, unknown>; } export type CheckoutEventCallback = (event: CheckoutEvent) => void; export type EventCallback = (data: Record<string, unknown>) => void; export type EventMap = Record<string, EventCallback[]>; export interface CheckoutConfig { mode: CheckoutMode; onEvent?: CheckoutEventCallback; linkType?: LinkType; theme?: ThemeType; displayType?: DisplayType; } export interface ProductItem { productId: string; quantity: number; } export interface OpenCheckoutOptions { products?: ProductItem[]; queryParams?: Record<string, string>; paymentLink?: string; redirectUrl?: string; } export interface CheckoutState { iframe: HTMLIFrameElement | null; container: HTMLDivElement | null; config: CheckoutConfig; currentProducts: ProductItem[]; baseUrl: string; allowedOrigin: string; iframeId: string; eventListeners: EventMap; }