Inttegro Web SDKs - v0.1.0
    Preparing search index...

    Interface CheckoutController

    Owns the lifecycle of one embedded hosted Checkout instance.

    Create a controller with InttegroRuntime.createCheckout, subscribe to events, and then mount it in an empty HTML element. A controller may be unmounted and mounted again, but cannot be reused after destroy(). Framework adapters manage this lifecycle automatically.

    const checkout = inttegro.createCheckout({ orderId })
    const unsubscribe = checkout.on('completed', handleCompleted)

    try {
    await checkout.mount(container)
    } catch (error) {
    showCheckoutUnavailable(error)
    }

    // When the surrounding view is permanently removed:
    unsubscribe()
    checkout.destroy()
    interface CheckoutController {
        state: CheckoutState;
        destroy(): void;
        focus(): void;
        mount(target: string | HTMLElement): Promise<void>;
        on<
            Type extends
                | "ready"
                | "change"
                | "paymentAttempt"
                | "confirmationRequired"
                | "paymentAttemptFailed"
                | "completed"
                | "canceled"
                | "error",
        >(
            type: Type,
            handler: CheckoutEventHandler<Type>,
        ): () => void;
        onEvent(handler: (event: CheckoutEvent) => void): () => void;
        unmount(): void;
        update(options: CheckoutUpdateOptions): void;
    }
    Index

    Read-only lifecycle state at the time it is accessed.

    • Permanently removes Checkout and all event subscriptions.

      Destruction is idempotent. A destroyed controller cannot be mounted again; create a new one if the flow must restart.

      Returns void

    • Moves focus into the first actionable control in hosted Checkout.

      Use this after opening Checkout in a dialog or when validation elsewhere on the page sends the payer back to payment collection.

      Returns void

      InttegroCheckoutError with not_mounted unless the controller is ready.

    • Creates the hosted iframe inside an empty target and waits until it is interactive.

      The target may be an element or a CSS selector. The promise resolves when the ready event is received. It rejects if the frame fails, times out, or is unmounted while initialization is pending; after those failures the controller returns to idle and may be mounted again.

      Parameters

      • target: string | HTMLElement

        Existing HTML element or CSS selector that resolves to one.

      Returns Promise<void>

      InttegroCheckoutError with unsupported_environment, destroyed, already_mounted, target_not_found, mount_failed, or mount_timeout.

    • Subscribes to one lifecycle event with a correctly narrowed payload type.

      Register before mount when listening for ready. The returned cleanup function should be called when the host view is removed unless the controller will immediately be destroyed.

      Type Parameters

      • Type extends
            | "ready"
            | "change"
            | "paymentAttempt"
            | "confirmationRequired"
            | "paymentAttemptFailed"
            | "completed"
            | "canceled"
            | "error"

        Event discriminator to observe.

      Parameters

      Returns () => void

      An idempotent function that removes this subscription.

    • Subscribes to every public lifecycle event.

      Register the handler before mount to observe initialization. A handler exception is rethrown in a microtask so it cannot stop Checkout or other subscribers; install your normal global error monitoring as well.

      Parameters

      • handler: (event: CheckoutEvent) => void

        Callback invoked for each sanitized event.

      Returns () => void

      An idempotent function that removes this subscription.

    • Removes the iframe and browser listeners while keeping the controller reusable.

      Calling this method during mounting rejects the outstanding mount promise with mount_failed. Calling it while idle or after destruction is safe. Event subscriptions remain registered for a later mount; call destroy for permanent cleanup.

      Returns void

    • Changes locale or color scheme without replacing the iframe.

      Updates made before ready are stored and applied during initialization. Ready controllers receive the update immediately. Invalid locales throw synchronously and leave the previous locale unchanged.

      Parameters

      Returns void

      InttegroCheckoutError with invalid_locale.