Callbacks

Reference for every SDK callback — when each fires, what data it receives, and how they sequence.

Callbacks are how you connect the checkout lifecycle to your own UI — showing a loading state while the session loads, redirecting after a completed order, or displaying an error message when payment fails. This page documents every callback the SDK exposes, where to register each one, and the shape of the data they receive.

Callback order

In a typical integration, callbacks fire in this sequence:

FastSpring.init() callbacks

Register these when initializing the SDK. They remain active for the lifetime of the sdk instance.

Fired when session data has been fetched and the checkout is ready for input.

const sdk = FastSpring.init({
    checkoutUrl: '...',
    onSessionLoaded: (data) => {
        document.querySelector('#loading-spinner').hidden = true;
    },
});
View data object
FieldTypeDescription
idstringThe session ID
itemsarrayLine items in the session
currencystringCurrency code (e.g. "USD")
totalnumberOrder total
complianceMessagesarrayCompliance flags for the session (e.g. "SHOW_IOF_MESSAGE" for Brazilian IOF fees)

sdk.checkout() callbacks

Register these per sdk.checkout() call. They fire once for that session load attempt.

Fired when the session loads successfully and the checkout is ready for input. No arguments.

sdk.checkout('<SESSION_ID>', {
    onSuccess: () => {
        console.log('Checkout is ready.');
    },
});

Related pages