/** * Configuration options for initializing the Fungies SDK * * @public */ type InitialFungiesOptions = { /** * Your Fungies API token */ token?: string; /** * Whether to enable HTML data attribute support for checkout buttons * When true (default), elements with data-fungies-checkout-id attributes * will automatically have click handlers attached * * @default true */ enableDataAttributes?: boolean; }; /** * Options for opening a checkout experience * * @public */ type InitialCheckoutOpenOptions = { /** * Settings for customizing the checkout experience */ settings: { /** * Target element selector for inline/embed checkouts * Only used when mode is 'embed' */ frameTarget?: string; /** * The display mode for the checkout * - 'overlay': Full-screen checkout that overlays the current page * - 'embed': Embedded checkout that renders within a container element */ mode: "embed" | "overlay"; }; /** * The unique identifier for the discount to be applied */ discountCode?: string; /** * The email address of the customer * @deprecated Use billingData.email instead */ customerEmail?: string; /** * Prefilled billing data for the checkout */ billingData?: { /** * The email address of the customer */ email?: string; /** * The first name of the customer */ firstName?: string; /** * The last name of the customer */ lastName?: string; /** * The country of the customer (ISO 3166-1 alpha-2 code) */ country?: string; /** * The state/province of the customer */ state?: string; /** * The city of the customer */ city?: string; /** * The zip/postal code of the customer */ zipCode?: string; }; /** * The quantity of the product to be purchased */ quantity?: number; /** * The items to be purchased * Each item must have an offerId that matches an offer configured in the dashboard * for the overlay or embed element. Only the quantity can be modified. */ items?: { /** * The unique identifier for the offer, must match an offer ID configured * in the dashboard for this checkout element */ offerId: string; /** * The quantity of this specific offer to be purchased */ quantity: number; }[]; /** * Custom fields to be added to the checkout */ customFields?: Record; /** * The URL of the checkout to be displayed * @required */ checkoutUrl: string; }; /** * Main interface for the Fungies SDK * * @public */ type FungiesInstance = { /** * Checkout functionality for opening and closing checkout experiences */ Checkout: { /** * Opens a checkout experience with the specified parameters * * @param parameters - Configuration options for the checkout * @returns void * * @example * ```ts * Fungies.Checkout.open({ * settings: { * mode: 'overlay', * // Optional: Only used for inline mode * frameTarget: 'target-element-id' * } * }); * ``` */ open: (parameters: InitialCheckoutOpenOptions) => void; /** * Closes any currently open checkout experience * * @returns void * * @example * ```ts * Fungies.Checkout.close(); * ``` */ close: () => void; }; /** * Initializes the Fungies SDK with the provided options * Must be called before using any other functionality * * @param options - Configuration options for the Fungies SDK * @returns void * * @example * ```ts * Fungies.Initialize({ * token: 'your-fungies-token', * // Optional: Set to false to disable HTML data attribute support * enableDataAttributes: true * }); * ``` * * @throws Will throw an error if token is not provided */ Initialize: (options: InitialFungiesOptions) => void; /** * Manually scans the DOM for elements with Fungies data attributes and attaches event handlers * Useful when dynamically adding checkout elements after initialization * * @returns void * * @example * ```ts * // After dynamically adding elements with data-fungies-checkout-id attributes * Fungies.ScanDOM(); * ``` * */ ScanDOM: () => void; }; declare global { interface Window { FungiesWindow?: Window; FungiesFrame?: HTMLIFrameElement; Fungies?: FungiesInstance; } } declare const Fungies: FungiesInstance; export { Fungies, type FungiesInstance, type InitialCheckoutOpenOptions, type InitialFungiesOptions };