Parameters

KeyTypeRequiredDescription
experienceIdstringYesID of the Paygate experience created in the Business Portal

Returns

A promise that resolves to the initial state of the Paygate and methods for showing it to users. Type of the response is PaygateExperienceResult.

FieldTypeDescription
initialStateExperienceStateSummaryThe state of the paygate immediately after config is loaded, can be used to check if the user is logged in or has a priort entitlement already.
logIn() => Promise<ExperienceStateSummary>Launch an auth flow immediately, if necessary. The returned promise resolves when the login flow is completed.
show() => Promise<ExperienceStateSummary>Display the paygate to the user, the returned promise resolves when the paygate closes.
destroy() => voidClean up and remove all Supertab elements from the DOM.

Example

const supertabClient = new Supertab({clientId: "client.your_client"});

const supertabPaygate = await supertabClient.createPaygate({
    experienceId: "experience.your_experience"
});

Types

ExperienceStateSummary

ExperienceStateSummary type definition
interface ExperienceStateSummary {
    priorEntitlement: EntitlementStatus[] | null;
    authStatus: AuthStatus;
    purchase: Purchase | null;
    purchasedOffering: Offering | null;
    tab: Tab | null;
    paymentResult: boolean;
}

type EntitlementStatus = {
    contentKey: string;
    hasEntitlement: boolean;
    expires: string;
    recursAt: Date | null;
}

enum AuthStatus {
    MISSING = "missing",
    EXPIRED = "expired",
    VALID = "valid"
}

type Purchase = {
    id: string;
    offeringId?: string | null;
    purchasedAt: string | null;
    completedAt: string | null;
    description: string;
    price: Price;
    status: PurchaseStatus;
    metadata: unknown;
    entitlementStatus: EntitlementStatus | null;
}

enum PurchaseStatus {
    PENDING = "pending",
    COMPLETED = "completed",
    ABANDONED = "abandoned"
}

type Price = {
    amount: number;
    currency: Currency;
}

type Currency = {
    code: string;
    symbol: string;
    name: string;
    baseUnit: number;
}

type Offering = {
    id: string;
    description: string;
    entitlementDetails: EntitlementDetails;
    price: Price;
    isPayNow: boolean;
}

type EntitlementDetails = {
    contentKey: string;
    duration: string;
    isRecurring: boolean;
}

type Tab = {
    testMode: boolean;
    currency: Currency;
    total: Price;
    limit: Price;
    purchases: Purchase[];
}

PaygateExperienceResult

PaygateExperienceResult type definition
interface PaygateExperienceResult {
    show: () => Promise<ExperienceStateSummary>;
    logIn: () => Promise<ExperienceStateSummary>;
    destroy: () => void;
    initialState: ExperienceStateSummary;
}