@revenuecat/purchases-js
Version:
Web subscriptions made easy. Powered by RevenueCat
1,134 lines (1,093 loc) • 39.4 kB
TypeScript
import { PaywallData } from '@revenuecat/purchases-ui-js';
/**
* @public
* `BrandingAppearance` defines the appearance settings
* of an app's branding configuration.
*/
export declare interface BrandingAppearance {
color_buttons_primary: string;
color_accent: string;
color_error: string;
color_product_info_bg: string;
color_form_bg: string;
color_page_bg: string;
font: string;
shapes: "default" | "rectangle" | "rounded" | "pill";
show_product_description: boolean;
}
/**
* Type containing all information regarding the customer.
* @public
*/
export declare interface CustomerInfo {
/**
* Entitlements attached to this customer info.
*/
readonly entitlements: EntitlementInfos;
/**
* Map of productIds to expiration dates.
*/
readonly allExpirationDatesByProduct: {
[productIdentifier: string]: Date | null;
};
/**
* Map of productIds to purchase dates.
*/
readonly allPurchaseDatesByProduct: {
[productIdentifier: string]: Date | null;
};
/**
* Set of active subscription product identifiers.
*/
readonly activeSubscriptions: Set<string>;
/**
* URL to manage the active subscription of the user.
* If this user has an active Web Billing subscription, a link to the management page.
* If this user has an active iOS subscription, this will point to the App Store.
* If the user has an active Play Store subscription it will point there.
* If there are no active subscriptions it will be null.
*/
readonly managementURL: string | null;
/**
* Date when this info was requested.
*/
readonly requestDate: Date;
/**
* The date this user was first seen in RevenueCat.
*/
readonly firstSeenDate: Date;
/**
* The purchase date for the version of the application when the user bought the app.
* Use this for grandfathering users when migrating to subscriptions. This can be null.
*/
readonly originalPurchaseDate: Date | null;
/**
* The original App User Id recorded for this user.
*/
readonly originalAppUserId: string;
/**
* The list of non-subscription transactions made by the user.
*/
readonly nonSubscriptionTransactions: NonSubscriptionTransaction[];
/**
* Dictionary of all subscription product identifiers and their subscription info.
*/
readonly subscriptionsByProductIdentifier: {
[productId: string]: SubscriptionInfo;
};
}
/**
* This object gives you access to all the information about the status
* of a user's entitlements.
* @public
*/
export declare interface EntitlementInfo {
/**
* The entitlement identifier configured in the RevenueCat dashboard.
*/
readonly identifier: string;
/**
* True if the user has access to the entitlement.
*/
readonly isActive: boolean;
/**
* True if the underlying subscription is set to renew at the end of the
* billing period (expirationDate). Will always be True if entitlement is
* for lifetime access.
*/
readonly willRenew: boolean;
/**
* The store where this entitlement was unlocked from.
*/
readonly store: Store;
/**
* The latest purchase or renewal date for the entitlement.
*/
readonly latestPurchaseDate: Date;
/**
* The first date this entitlement was purchased.
*/
readonly originalPurchaseDate: Date;
/**
* The expiration date for the entitlement, can be `null` for lifetime
* access. If the {@link EntitlementInfo.periodType} is `trial`, this is the trial
* expiration date.
*/
readonly expirationDate: Date | null;
/**
* The product identifier that unlocked this entitlement.
*/
readonly productIdentifier: string;
/**
* The base plan identifier that unlocked this entitlement (For Google Play subs only).
*/
readonly productPlanIdentifier: string | null;
/**
* The date an unsubscribe was detected. Can be `null`.
* Note: Entitlement may still be active even if user has unsubscribed.
* Check the {@link EntitlementInfo.isActive} property.
*/
readonly unsubscribeDetectedAt: Date | null;
/**
* The date a billing issue was detected. Can be `null` if there is
* no billing issue or an issue has been resolved. Note: Entitlement may
* still be active even if there is a billing issue.
* Check the `isActive` property.
*/
readonly billingIssueDetectedAt: Date | null;
/**
* False if this entitlement is unlocked via a production purchase.
*/
readonly isSandbox: boolean;
/**
* The last period type this entitlement was in.
*/
readonly periodType: PeriodType;
/**
* Use this property to determine whether a purchase was made by the
* current user or shared to them by a family member. This can be useful
* for onboarding users who have had an entitlement shared with them,
* but might not be entirely aware of the benefits they now have.
*/
readonly ownershipType: OwnershipType | null;
}
/**
* Contains all the entitlements associated to the user.
* @public
*/
export declare interface EntitlementInfos {
/**
* Map of all {@link EntitlementInfo} objects (active and inactive) keyed by
* entitlement identifier.
*/
readonly all: {
[entitlementId: string]: EntitlementInfo;
};
/**
* Dictionary of active {@link EntitlementInfo} keyed by entitlement identifier.
*/
readonly active: {
[entitlementId: string]: EntitlementInfo;
};
}
/**
* Error codes for the Purchases SDK.
* @public
*/
export declare enum ErrorCode {
UnknownError = 0,
UserCancelledError = 1,
StoreProblemError = 2,
PurchaseNotAllowedError = 3,
PurchaseInvalidError = 4,
ProductNotAvailableForPurchaseError = 5,
ProductAlreadyPurchasedError = 6,
ReceiptAlreadyInUseError = 7,
InvalidReceiptError = 8,
MissingReceiptFileError = 9,
NetworkError = 10,
InvalidCredentialsError = 11,
UnexpectedBackendResponseError = 12,
InvalidAppUserIdError = 14,
OperationAlreadyInProgressError = 15,
UnknownBackendError = 16,
InvalidAppleSubscriptionKeyError = 17,
IneligibleError = 18,
InsufficientPermissionsError = 19,
PaymentPendingError = 20,
InvalidSubscriberAttributesError = 21,
LogOutWithAnonymousUserError = 22,
ConfigurationError = 23,
UnsupportedError = 24,
EmptySubscriberAttributesError = 25,
CustomerInfoError = 28,
SignatureVerificationError = 36,
InvalidEmailError = 38
}
/**
* Flags used to enable or disable certain features in the sdk.
* @public
*/
export declare interface FlagsConfig {
/**
* If set to true, the SDK will automatically collect UTM parameters and store them as at the time of purchase.
* @defaultValue true
*/
autoCollectUTMAsMetadata?: boolean;
/**
* If set to true, the SDK will automatically collect analytics events.
* @defaultValue true
*/
collectAnalyticsEvents?: boolean;
}
/**
* Parameters for the {@link Purchases.getOfferings} method.
* @public
*/
export declare interface GetOfferingsParams {
/**
* The currency code in ISO 4217 to fetch the offerings for.
* If not specified, the default currency will be used.
*/
readonly currency?: string;
/**
* The identifier of the offering to fetch.
* Can be a string identifier or one of the predefined keywords.
*/
readonly offeringIdentifier?: string | OfferingKeyword;
}
/**
* Parameters used to customise the http requests executed by purchases-js.
* @public
*/
export declare interface HttpConfig {
/**
* Additional headers to include in all HTTP requests.
*/
additionalHeaders?: Record<string, string>;
/**
* Set this property to your proxy URL *only* if you've received a proxy
* key value from your RevenueCat contact. This value should never end with
* a trailing slash.
*/
proxyURL?: string;
}
/**
* Possible levels to log in the console.
* @public
*/
export declare enum LogLevel {
/**
* No logs will be shown in the console.
*/
Silent = 0,
/**
* Only errors will be shown in the console.
*/
Error = 1,
/**
* Only warnings and errors will be shown in the console.
*/
Warn = 2,
/**
* Only info, warnings, and errors will be shown in the console.
*/
Info = 3,
/**
* Debug, info, warnings, and errors will be shown in the console.
*/
Debug = 4,
/**
* All logs will be shown in the console.
*/
Verbose = 5
}
/**
* Represents a possible option to purchase a non-subscription product.
* @public
*/
export declare interface NonSubscriptionOption extends PurchaseOption {
/**
* The base price for the product.
*/
readonly basePrice: Price;
}
/**
* Information that represents a non-subscription purchase made by a user.
* @public
*/
export declare interface NonSubscriptionTransaction {
/**
* The unique identifier for the transaction created by RevenueCat.
*/
readonly transactionIdentifier: string;
/**
* The product identifier.
*/
readonly productIdentifier: string;
/**
* The date that the store charged the user’s account.
*/
readonly purchaseDate: Date;
/**
* The unique identifier for the transaction created by the Store.
*/
readonly storeTransactionId: string | null;
/**
* The {@link Store} where the transaction was made.
*/
readonly store: Store;
}
/**
* An offering is a collection of {@link Package} available for the user to purchase.
* For more info see https://docs.revenuecat.com/docs/entitlements
* @public
*/
export declare interface Offering {
/**
* Unique identifier defined in RevenueCat dashboard.
*/
readonly identifier: string;
/**
* Offering description defined in RevenueCat dashboard.
*/
readonly serverDescription: string;
/**
* Offering metadata defined in RevenueCat dashboard.
*/
readonly metadata: {
[key: string]: unknown;
} | null;
/**
* A map of all the packages available for purchase keyed by package ID.
*/
readonly packagesById: {
[key: string]: Package;
};
/**
* A list of all the packages available for purchase.
*/
readonly availablePackages: Package[];
/**
* Lifetime package type configured in the RevenueCat dashboard, if available.
*/
readonly lifetime: Package | null;
/**
* Annual package type configured in the RevenueCat dashboard, if available.
*/
readonly annual: Package | null;
/**
* Six month package type configured in the RevenueCat dashboard, if available.
*/
readonly sixMonth: Package | null;
/**
* Three month package type configured in the RevenueCat dashboard, if available.
*/
readonly threeMonth: Package | null;
/**
* Two month package type configured in the RevenueCat dashboard, if available.
*/
readonly twoMonth: Package | null;
/**
* Monthly package type configured in the RevenueCat dashboard, if available.
*/
readonly monthly: Package | null;
/**
* Weekly package type configured in the RevenueCat dashboard, if available.
*/
readonly weekly: Package | null;
readonly paywall_components: PaywallData | null;
}
/**
* Keywords for identifying specific offerings in the {@link Purchases.getOfferings} method.
* @public
*/
export declare enum OfferingKeyword {
/**
* The current offering.
*/
Current = "current"
}
/**
* This class contains all the offerings configured in RevenueCat dashboard.
* For more info see https://docs.revenuecat.com/docs/entitlements
* @public
*/
export declare interface Offerings {
/**
* Dictionary containing all {@link Offering} objects, keyed by their identifier.
*/
readonly all: {
[offeringId: string]: Offering;
};
/**
* Current offering configured in the RevenueCat dashboard.
* It can be `null` if no current offering is configured or if a specific offering
* was requested that is not the current one.
*/
readonly current: Offering | null;
}
/**
* The types used to describe whether a transaction was purchased by the user,
* or is available to them through Family Sharing.
* @public
*/
export declare type OwnershipType = "PURCHASED" | "FAMILY_SHARED" | "UNKNOWN";
/**
* Contains information about the product available for the user to purchase.
* For more info see https://docs.revenuecat.com/docs/entitlements
* @public
*/
export declare interface Package {
/**
* Unique identifier for this package. Can be one a predefined package type or a custom one.
*/
readonly identifier: string;
/**
* The {@link Product} assigned to this package.
* @deprecated - Use {@link Package.webBillingProduct} instead.
*/
readonly rcBillingProduct: Product;
/**
* The {@link Product} assigned to this package.
*/
readonly webBillingProduct: Product;
/**
* The type of package.
*/
readonly packageType: PackageType;
}
/**
* Enumeration of all possible Package types.
* @public
*/
export declare enum PackageType {
/**
* A package that was defined with an unrecognized RC identifier.
*/
Unknown = "unknown",
/**
* A package that was defined with a custom identifier.
*/
Custom = "custom",
/**
* A package configured with the predefined lifetime identifier.
*/
Lifetime = "$rc_lifetime",
/**
* A package configured with the predefined annual identifier.
*/
Annual = "$rc_annual",
/**
* A package configured with the predefined six month identifier.
*/
SixMonth = "$rc_six_month",
/**
* A package configured with the predefined three month identifier.
*/
ThreeMonth = "$rc_three_month",
/**
* A package configured with the predefined two month identifier.
*/
TwoMonth = "$rc_two_month",
/**
* A package configured with the predefined monthly identifier.
*/
Monthly = "$rc_monthly",
/**
* A package configured with the predefined weekly identifier.
*/
Weekly = "$rc_weekly"
}
/**
* Represents a period of time.
* @public
*/
export declare interface Period {
/**
* The number of units in the period.
*/
number: number;
/**
* The unit of time.
*/
unit: PeriodUnit;
}
/**
* Supported period types for an entitlement.
* - "normal" If the entitlement is not under an introductory or trial period.
* - "intro" If the entitlement is under an introductory period.
* - "trial" If the entitlement is under a trial period.
* - "prepaid" If the entitlement is a prepaid entitlement. Only for Google Play subscriptions.
* @public
*/
export declare type PeriodType = "normal" | "intro" | "trial" | "prepaid";
/**
* Represents a unit of time.
* @public
*/
export declare enum PeriodUnit {
Year = "year",
Month = "month",
Week = "week",
Day = "day"
}
/**
* PlatformInfo is an interface that represents the information about the platform.
* Used by RevenueCat Hybrid SDKs to provide information about the platform.
* @public
* @experimental
*/
export declare interface PlatformInfo {
/**
* The flavor of the SDK.
*/
readonly flavor: string;
/**
* The version of the hybrid SDK.
*/
readonly version: string;
}
/**
* Contains data about the context in which an offering was presented.
* @public
*/
export declare interface PresentedOfferingContext {
/**
* The identifier of the offering used to obtain this object.
*/
readonly offeringIdentifier: string;
/**
* The targeting context used to obtain this object.
*/
readonly targetingContext: TargetingContext | null;
/**
* If obtained this information from a placement,
* the identifier of the placement.
*/
readonly placementIdentifier: string | null;
}
/**
* Price information for a product.
* @public
*/
export declare interface Price {
/**
* Price in cents of the currency.
* @deprecated - Use {@link Price.amountMicros} instead.
*/
readonly amount: number;
/**
* Price in micro-units of the currency. For example, $9.99 is represented as 9990000.
*/
readonly amountMicros: number;
/**
* Returns ISO 4217 currency code for price.
* For example, if price is specified in British pounds sterling,
* currency is "GBP".
* If currency code cannot be determined, currency symbol is returned.
*/
readonly currency: string;
/**
* Formatted price string including price and currency.
*/
readonly formattedPrice: string;
}
/**
* Represents the price and duration information for a phase of the purchase option.
* @public
*/
export declare interface PricingPhase {
/**
* The duration of the phase in ISO 8601 format.
*/
readonly periodDuration: string | null;
/**
* The duration of the phase as a {@link Period}.
*/
readonly period: Period | null;
/**
* The price for the purchase option.
* Null in case of trials.
*/
readonly price: Price | null;
/**
* The number of cycles this option's price repeats.
* I.e. 2 subscription cycles, 0 if not applicable.
*/
readonly cycleCount: number;
/**
* The approximated price converted to weekly rate, based on the period information.
* Null in case of trials.
*/
readonly pricePerWeek: Price | null;
/**
* The approximated price converted to monthly rate, based on the period information.
* Null in case of trials.
*/
readonly pricePerMonth: Price | null;
/**
* The approximated price converted to yearly rate, based on the period information.
* Null in case of trials.
*/
readonly pricePerYear: Price | null;
}
/**
* Represents product's listing details.
* @public
*/
export declare interface Product {
/**
* The product ID.
*/
readonly identifier: string;
/**
* Name of the product.
* @deprecated - Use {@link Product.title} instead.
*/
readonly displayName: string;
/**
* The title of the product as configured in the RevenueCat dashboard.
*/
readonly title: string;
/**
* The description of the product as configured in the RevenueCat dashboard.
*/
readonly description: string | null;
/**
* Price of the product. This will match the default option's base phase price
* in subscriptions or the price in non-subscriptions.
*/
readonly currentPrice: Price;
/**
* The type of product.
*/
readonly productType: ProductType;
/**
* The period duration for a subscription product. This will match the default
* option's base phase period duration. Null for non-subscriptions.
*/
readonly normalPeriodDuration: string | null;
/**
* The offering ID used to obtain this product.
* @deprecated - Use {@link Product.presentedOfferingContext} instead.
*/
readonly presentedOfferingIdentifier: string;
/**
* The context from which this product was obtained.
*/
readonly presentedOfferingContext: PresentedOfferingContext;
/**
* The default purchase option for this product.
*/
readonly defaultPurchaseOption: PurchaseOption;
/**
* The default subscription option for this product.
* Null if no subscription options are available like in the case of consumables and non-consumables.
*/
readonly defaultSubscriptionOption: SubscriptionOption | null;
/**
* A dictionary with all the possible subscription options available for this
* product. Each key contains the key to be used when executing a purchase.
* Will be empty for non-subscriptions
*
* If retrieved through getOfferings the offers are only the ones the customer is
* entitled to.
*/
readonly subscriptionOptions: {
[optionId: string]: SubscriptionOption;
};
/**
* The default non-subscription option for this product.
* Null in the case of subscriptions.
*/
readonly defaultNonSubscriptionOption: NonSubscriptionOption | null;
}
/**
* Possible product types
* @public
*/
export declare enum ProductType {
/**
* A product that is an auto-renewing subscription.
*/
Subscription = "subscription",
/**
* A product that does not renew and can be consumed to be purchased again.
*/
Consumable = "consumable",
/**
* A product that does not renew and can only be purchased once.
*/
NonConsumable = "non_consumable"
}
/**
* Metadata that can be passed to the backend when making a purchase.
* They will propagate to the payment gateway (i.e. Stripe) and to RevenueCat.
* @public
*/
export declare type PurchaseMetadata = Record<string, string | null>;
/**
* Represents a possible option to purchase a product.
* @public
*/
export declare interface PurchaseOption {
/**
* The unique id for a purchase option
*/
readonly id: string;
/**
* The public price id for this subscription option.
*/
readonly priceId: string;
}
/**
* Parameters used to customise the purchase flow when invoking the `.purchase` method.
* @public
*/
export declare interface PurchaseParams {
/**
* The package you want to purchase. Obtained from {@link Purchases.getOfferings}.
*/
rcPackage: Package;
/**
* The option to be used for this purchase. If not specified or null the default one will be used.
*/
purchaseOption?: PurchaseOption | null;
/**
* The HTML element where the billing view should be added. If undefined, a new div will be created at the root of the page and appended to the body.
*/
htmlTarget?: HTMLElement;
/**
* The email of the user. If undefined, RevenueCat will ask the customer for their email.
*/
customerEmail?: string;
/**
* The locale to use for the purchase flow. If not specified, English will be used
*/
selectedLocale?: string;
/**
* The default locale to use if the selectedLocale is not available.
* Defaults to english.
*/
defaultLocale?: string;
/**
* 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.
*/
metadata?: PurchaseMetadata;
}
/**
* Represents the result of a purchase operation.
* @public
*/
export declare interface PurchaseResult {
/**
* The customer information after the purchase.
*/
readonly customerInfo: CustomerInfo;
/**
* The redemption information after the purchase if available.
*/
readonly redemptionInfo: RedemptionInfo | null;
/**
* The operation session id of the purchase.
*/
readonly operationSessionId: string;
}
/**
* Entry point for Purchases SDK. It should be instantiated as soon as your
* app is started. Only one instance of Purchases should be instantiated
* at a time!
* @public
*/
export declare class Purchases {
/**
* Set the log level. Logs of the given level and below will be printed
* in the console.
* Default is `LogLevel.Silent` so no logs will be printed in the console.
* @param logLevel - LogLevel to set.
*/
static setLogLevel(logLevel: LogLevel): void;
/**
* Meant to be used by RevenueCat hybrids SDKS only.
* @experimental
* */
static setPlatformInfo(platformInfo: PlatformInfo): void;
/**
* Get the singleton instance of Purchases. It's preferred to use the instance
* obtained from the {@link Purchases.configure} method when possible.
* @throws {@link UninitializedPurchasesError} if the instance has not been initialized yet.
*/
static getSharedInstance(): Purchases;
/**
* Returns whether the Purchases SDK is configured or not.
*/
static isConfigured(): boolean;
/**
* Configures the Purchases SDK. This should be called as soon as your app
* has a unique user id for your user. You should only call this once, and
* keep the returned instance around for use throughout your application.
* @param apiKey - RevenueCat API Key. Can be obtained from the RevenueCat dashboard.
* @param appUserId - Your unique id for identifying the user.
* @param httpConfig - Advanced http configuration to customise the SDK usage {@link HttpConfig}.
* @param flags - Advanced functionality configuration {@link FlagsConfig}.
* @throws {@link PurchasesError} if the API key or user id are invalid.
*/
static configure(apiKey: string, appUserId: string, httpConfig?: HttpConfig, flags?: FlagsConfig): Purchases;
/**
* Loads and caches some optional data in the Purchases SDK.
* Currently only fetching branding information.
* You can call this method after configuring the SDK to speed
* up the first call to {@link Purchases.purchase}.
*/
preload(): Promise<void>;
/**
* Fetch the configured offerings for this user. You can configure these
* in the RevenueCat dashboard.
* @param params - The parameters object to customise the offerings fetch. Check {@link GetOfferingsParams}
*/
getOfferings(params?: GetOfferingsParams): Promise<Offerings>;
/**
* Retrieves a specific offering by a placement identifier.
* For more info see https://www.revenuecat.com/docs/tools/targeting
* @param placementIdentifier - The placement identifier to retrieve the offering for.
* @param params - The parameters object to customise the offerings fetch. Check {@link GetOfferingsParams}
*/
getCurrentOfferingForPlacement(placementIdentifier: string, params?: GetOfferingsParams): Promise<Offering | null>;
private getAllOfferings;
/**
* Convenience method to check whether a user is entitled to a specific
* entitlement. This will use {@link Purchases.getCustomerInfo} under the hood.
* @param entitlementIdentifier - The entitlement identifier you want to check.
* @returns Whether the user is entitled to the specified entitlement
* @throws {@link PurchasesError} if there is an error while fetching the customer info.
* @see {@link Purchases.getCustomerInfo}
*/
isEntitledTo(entitlementIdentifier: string): Promise<boolean>;
/**
* Method to perform a purchase for a given package. You can obtain the
* package from {@link Purchases.getOfferings}. This method will present the purchase
* form on your site, using the given HTML element as the mount point, if
* provided, or as a modal if not.
* @deprecated - please use .purchase
* @param rcPackage - The package you want to purchase. Obtained from {@link Purchases.getOfferings}.
* @param customerEmail - The email of the user. If undefined, RevenueCat will ask the customer for their email.
* @param htmlTarget - The HTML element where the billing view should be added. If undefined, a new div will be created at the root of the page and appended to the body.
* @returns a Promise for the customer info after the purchase is completed successfully.
* @throws {@link PurchasesError} if there is an error while performing the purchase. If the {@link PurchasesError.errorCode} is {@link ErrorCode.UserCancelledError}, the user cancelled the purchase.
*/
purchasePackage(rcPackage: Package, customerEmail?: string, htmlTarget?: HTMLElement): Promise<PurchaseResult>;
/**
* Method to perform a purchase for a given package. You can obtain the
* package from {@link Purchases.getOfferings}. This method will present the purchase
* form on your site, using the given HTML element as the mount point, if
* provided, or as a modal if not.
* @param params - The parameters object to customise the purchase flow. Check {@link PurchaseParams}
* @returns a Promise for the customer and redemption info after the purchase is completed successfully.
* @throws {@link PurchasesError} if there is an error while performing the purchase. If the {@link PurchasesError.errorCode} is {@link ErrorCode.UserCancelledError}, the user cancelled the purchase.
*/
purchase(params: PurchaseParams): Promise<PurchaseResult>;
/**
* Gets latest available {@link CustomerInfo}.
* @returns The latest {@link CustomerInfo}.
* @throws {@link PurchasesError} if there is an error while fetching the customer info.
*/
getCustomerInfo(): Promise<CustomerInfo>;
/**
* Gets the current app user id.
*/
getAppUserId(): string;
/**
* Change the current app user id. Returns the customer info for the new
* user id.
* @param newAppUserId - The user id to change to.
*/
changeUser(newAppUserId: string): Promise<CustomerInfo>;
/**
* @returns Whether the SDK is using a sandbox API Key.
*/
isSandbox(): boolean;
/**
* Closes the Purchases instance. You should never have to do this normally.
*/
close(): void;
/**
* Generates an anonymous app user ID that follows RevenueCat's format.
* This can be used when you don't have a user identifier system in place.
* The generated ID will be in the format: $RCAnonymousID:\<UUID without dashes\>
* Example: $RCAnonymousID:123e4567e89b12d3a456426614174000
* @returns A new anonymous app user ID string
* @public
*/
static generateRevenueCatAnonymousAppUserId(): string;
}
/**
* Error class for Purchases SDK. You should handle these errors and react
* accordingly in your app.
* @public
*/
export declare class PurchasesError extends Error {
/**
* Error code for the error. This is useful to appropriately react to
* different error situations.
*/
readonly errorCode: ErrorCode;
/**
* Underlying error message. This provides more details on the error and
* can be useful for debugging and logging.
*/
readonly underlyingErrorMessage?: string | null | undefined;
/**
* Contains extra information that is available in certain types of errors.
*/
readonly extra?: PurchasesErrorExtra | undefined;
constructor(
/**
* Error code for the error. This is useful to appropriately react to
* different error situations.
*/
errorCode: ErrorCode,
/**
* Message for the error. This is useful for debugging and logging.
*/
message?: string,
/**
* Underlying error message. This provides more details on the error and
* can be useful for debugging and logging.
*/
underlyingErrorMessage?: string | null | undefined,
/**
* Contains extra information that is available in certain types of errors.
*/
extra?: PurchasesErrorExtra | undefined);
toString: () => string;
}
/**
* Extra information that is available in certain types of errors.
* @public
*/
export declare interface PurchasesErrorExtra {
/**
* If this is a request error, the HTTP status code of the response.
*/
readonly statusCode?: number;
/**
* If this is a RevenueCat backend error, the error code from the servers.
*/
readonly backendErrorCode?: number;
}
/**
* This object gives you access to the purchase redemption data when
* the purchase can be redeemed to a mobile user, like in the case of anonymous users.
* @public
*/
export declare interface RedemptionInfo {
/**
* The redeem url.
*/
readonly redeemUrl: string | null;
}
/**
* The store where the user originally subscribed.
* @public
*/
export declare type Store = "app_store" | "mac_app_store" | "play_store" | "amazon" | "stripe" | "rc_billing" | "promotional" | "unknown";
/**
* Subscription purchases of the Customer.
* @public
*/
export declare interface SubscriptionInfo {
/**
* The product identifier.
*/
readonly productIdentifier: string;
/**
* Date when the last subscription period started.
*/
readonly purchaseDate: Date;
/**
* Date when this subscription first started. This property does not update with renewals.
* This property also does not update for product changes within a subscription group or
* re-subscriptions by lapsed subscribers.
*/
readonly originalPurchaseDate: Date | null;
/**
* Date when the subscription expires/expired
*/
readonly expiresDate: Date | null;
/**
* Store where the subscription was purchased.
*/
readonly store: Store;
/**
* Date when RevenueCat detected that auto-renewal was turned off for this subscription.
* Note the subscription may still be active, check the {@link SubscriptionInfo.expiresDate} attribute.
*/
readonly unsubscribeDetectedAt: Date | null;
/**
* Whether or not the purchase was made in sandbox mode.
*/
readonly isSandbox: boolean;
/**
* Date when RevenueCat detected any billing issues with this subscription.
* If and when the billing issue gets resolved, this field is set to null.
* Note the subscription may still be active, check the {@link SubscriptionInfo.expiresDate} attribute.
*/
readonly billingIssuesDetectedAt: Date | null;
/**
* Date when any grace period for this subscription expires/expired.
* null if the customer has never been in a grace period.
*/
readonly gracePeriodExpiresDate: Date | null;
/**
* How the Customer received access to this subscription:
* - "PURCHASED": The customer bought the subscription.
* - "FAMILY_SHARED": The customer has access to the product via their family.
*/
readonly ownershipType: OwnershipType;
/**
* Type of the current subscription period:
* - "normal": The product is in a normal period (default)
* - "trial": The product is in a free trial period
* - "intro": The product is in an introductory pricing period
* - "prepaid": The product is in a prepaid pricing period
*/
readonly periodType: PeriodType;
/**
* Date when RevenueCat detected a refund of this subscription.
*/
readonly refundedAt: Date | null;
/**
* The transaction id in the store of the subscription.
*/
readonly storeTransactionId: string | null;
/**
* Whether the subscription is currently active
* (at the time this object was obtained).
*/
readonly isActive: boolean;
/**
* Whether the subscription will renew at the next billing period.
*/
readonly willRenew: boolean;
}
/**
* Represents a possible option to purchase a subscription product.
* @public
*/
export declare interface SubscriptionOption extends PurchaseOption {
/**
* The base phase for a SubscriptionOption, represents
* the price that the customer will be charged after all the discounts have
* been consumed and the period at which it will renew.
*/
readonly base: PricingPhase;
/**
* The trial information for this subscription option if available.
*/
readonly trial: PricingPhase | null;
}
/**
* Contains information about the targeting context used to obtain an object.
* @public
*/
export declare interface TargetingContext {
/**
* The rule id from the targeting used to obtain this object.
*/
readonly ruleId: string;
/**
* The revision of the targeting used to obtain this object.
*/
readonly revision: number;
}
/**
* Error indicating that the SDK was accessed before it was initialized.
* @public
*/
export declare class UninitializedPurchasesError extends Error {
constructor();
}
export { }