Interface PresentExpressPurchaseButtonParamsExperimental

Parameters for the Purchases.presentExpressPurchaseButton method.

const offerings = await purchases.getOfferings();
const pkg = offerings.current?.availablePackages[0];
const htmlTarget = document.getElementById("express-purchase-button");
const fallbackButton = document.getElementById("checkout-button");

if (pkg && htmlTarget) {
let expressButtonUpdater: ExpressPurchaseButtonUpdater | undefined;

void purchases.presentExpressPurchaseButton({
rcPackage: pkg,
htmlTarget,
onButtonReady: (updater, walletsAvailable) => {
expressButtonUpdater = updater;
htmlTarget.hidden = !walletsAvailable;

if (fallbackButton) {
fallbackButton.hidden = walletsAvailable;
}
},
});

// If the customer selects a different package later, update the button
// instead of rendering a new one.
function onSelectedPackageChanged(nextPackage: Package) {
expressButtonUpdater?.updatePurchase(nextPackage);
}
}
interface PresentExpressPurchaseButtonParams {
    customerEmail?: string;
    defaultLocale?: string;
    htmlTarget: HTMLElement;
    listener?: PurchaseListener;
    metadata?: PurchaseMetadata;
    onButtonReady?: (
        updater: ExpressPurchaseButtonUpdater,
        walletsAvailable: boolean,
    ) => void;
    purchaseOption?: null | PurchaseOption;
    rcPackage: Package;
    selectedLocale?: string;
    walletButtonTheme?: WalletButtonTheme;
}

Properties

customerEmail?: string

The email of the user. If undefined, RevenueCat will ask the customer for their email.

defaultLocale?: string

The default locale to use if the selectedLocale is not available. Defaults to english.

htmlTarget: HTMLElement

The HTML element where the express purchase button should be rendered.

listener?: PurchaseListener

Optional listener for purchase lifecycle events.

metadata?: PurchaseMetadata

The purchase metadata to be passed to the backend. Any information provided here will be propagated to the payment gateway and to the RC transaction as metadata.

onButtonReady?: (
    updater: ExpressPurchaseButtonUpdater,
    walletsAvailable: boolean,
) => void

Callback to be called when the express purchase button is ready to be clicked.

purchaseOption?: null | PurchaseOption

The option to be used for this purchase. If not specified or null the default one will be used.

rcPackage: Package

The package you want to purchase. Obtained from Purchases.getOfferings.

selectedLocale?: string

The locale to use for the purchase flow. If not specified, English will be used

walletButtonTheme?: WalletButtonTheme

Theme for the Stripe wallet button appearance. Matches Apple Pay button styles: 'black', 'white', or 'white-outline' Defaults to "black".