Available in paywall script version 1.0.3 and later
If you have a tokenized paywall, skip this section — it's only relevant for regular paywalls. To get remaining tokens please use Get user data (paywall.getUser)
Retrieves information about the current trial state for the paywall.
/** * Represents a time-based trial information */ interface TimeBasedTrial { /** Timestamp when trial period started (in milliseconds) */ expirationStart: number; /** Timestamp when trial period ends (in milliseconds) */ expirationEnd: number; /** Total duration of trial period (in milliseconds) */ expirationTime: number; /** Whether the trial period has expired */ expired: boolean; } /** * Represents an opens/actions-based trial information */ interface OpensBasedTrial { /** Number of remaining trial actions available */ remainingActions: number; /** Total number of actions allowed in trial */ totalActions: number; /** Whether all trial actions have been used */ expired: boolean; } /** All possible trial information types */ type TrialInfo = TimeBasedTrial | OpensBasedTrial | 'no trial'; interface Paywall { /** * Retrieves information about the current trial state for the paywall. * The method supports two types of trials: time-based and opens-based. * * @throws {Error} If the request fails or paywall is not initialized * * @example * // Get trial information * const trialInfo = await paywall.getTrialInfo(); * * if (trialInfo === 'no trial') { * console.log('No trial available'); * } else if ('expirationTime' in trialInfo) { * // Handle time-based trial * console.log(`Trial expires in ${trialInfo.expirationTime} ms`); * } else { * // Handle opens-based trial * console.log(`${trialInfo.remainingActions} actions remaining`); * } */ getTrialInfo(): Promise<TrialInfo>; }