Controls a Checkout Session, including its state, Payment Element, mutations, and confirmation flow.

This API is in private preview and can change without notice.

interface CheckoutController {
    status: "ready" | "updating" | "confirming" | "destroyed";
    session: Checkout.Session;
    paymentElement: CheckoutPaymentElement;
    updateEmail(email: null | string): Promise<void>;
    updateShippingAddress(params: UpdateShippingAddressParams): Promise<void>;
    applyPromotionCode(promotionCode: string): Promise<void>;
    removePromotionCode(): Promise<void>;
    runServerUpdate(serverUpdate: () => Promise<void>): Promise<void>;
    clearPaymentOption(): Promise<void>;
    confirm(): Promise<Checkout.Result>;
    destroy(): Promise<void>;
}

Properties

status: "ready" | "updating" | "confirming" | "destroyed"

The controller lifecycle status. Disable mutation and confirmation UI unless this is ready.

session: Checkout.Session

The latest snapshot of the customer's Checkout Session.

paymentElement: CheckoutPaymentElement

The Payment Element owned by this controller.

Methods

  • Updates the customer's email address. Pass null to clear it.

    Parameters

    • email: null | string

    Returns Promise<void>

  • Applies a promotion code after trimming leading and trailing whitespace.

    Parameters

    • promotionCode: string

    Returns Promise<void>

  • Removes the currently applied promotion code, if any.

    Returns Promise<void>

  • Runs a server update, then refreshes the local Checkout Session.

    Parameters

    • serverUpdate: () => Promise<void>

    Returns Promise<void>

  • Clears the customer's currently selected payment option.

    Returns Promise<void>

  • Confirms the Checkout Session for the selected payment option.

    Returns Promise<Checkout.Result>

  • Releases the controller's native resources and clears its loaded state.

    Returns Promise<void>