Reactive Checkout state and controller methods returned by useCheckout.

interface UseResult {
    status:
        | "error"
        | "ready"
        | "updating"
        | "confirming"
        | "idle"
        | "loading";
    session: null
    | Checkout.Session;
    paymentElement: null | CheckoutPaymentElement;
    error: null | StripeError<ErrorCode>;
    reload(): Promise<void>;
    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>;
}

Properties

status: "error" | "ready" | "updating" | "confirming" | "idle" | "loading"

The current hook or controller lifecycle status.

session: null | Checkout.Session

The latest session snapshot, or null before Checkout is ready.

paymentElement: null | CheckoutPaymentElement

The Checkout-owned Payment Element, or null before Checkout is ready.

error: null | StripeError<ErrorCode>

The initialization error when status is error; otherwise null.

Methods

  • Fetches fresh configuration and replaces the current native controller.

    Returns Promise<void>

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

    Parameters

    • email: null | string

    Returns Promise<void>

  • Applies a promotion code entered by the customer.

    Parameters

    • promotionCode: string

    Returns Promise<void>

  • Removes the currently applied promotion code, if any.

    Returns Promise<void>

  • Runs a server update and 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>