UNPKG

@revenuecat/purchases-js

Version:

Web subscriptions made easy. Powered by RevenueCat

1,374 lines (1,316 loc) 86.1 kB
import { CompleteWorkflowNavigateArgs } from '@revenuecat/purchases-ui-js'; import { CustomVariables } from '@revenuecat/purchases-ui-js'; import { CustomVariableValue } from '@revenuecat/purchases-ui-js'; import { PaywallData } from '@revenuecat/purchases-ui-js'; import { UIConfig } from '@revenuecat/purchases-ui-js'; import { WalletButtonRender } from '@revenuecat/purchases-ui-js'; import { WalletButtonTheme } from '@revenuecat/purchases-ui-js'; /* Excluded from this release type: AttributionMetadata */ declare enum BackendErrorCode { BackendInvalidPlatform = 7000, BackendInvalidEmail = 7012, BackendStoreProblem = 7101, BackendCannotTransferPurchase = 7102, BackendInvalidReceiptToken = 7103, BackendInvalidAppStoreSharedSecret = 7104, BackendInvalidPaymentModeOrIntroPriceNotProvided = 7105, BackendProductIdForGoogleReceiptNotProvided = 7106, BackendInvalidPlayStoreCredentials = 7107, BackendInternalServerError = 7110, BackendEmptyAppUserId = 7220, BackendInvalidAuthToken = 7224, BackendInvalidAPIKey = 7225, BackendBadRequest = 7226, BackendPlayStoreQuotaExceeded = 7229, BackendPlayStoreInvalidPackageName = 7230, BackendPlayStoreGenericError = 7231, BackendUserIneligibleForPromoOffer = 7232, BackendInvalidAppleSubscriptionKey = 7234, BackendSubscriberNotFound = 7259, BackendInvalidSubscriberAttributes = 7263, BackendInvalidSubscriberAttributesBody = 7264, BackendProductIDsMalformed = 7662, BackendAlreadySubscribedError = 7772, BackendPaymentGatewayGenericError = 7773, BackendOfferNotFound = 7814, BackendNoMXRecordsFound = 7834, BackendInvalidOperationSession = 7877, BackendPurchaseCannotBeCompleted = 7878, BackendEmailIsRequired = 7879, BackendGatewaySetupErrorStripeTaxNotActive = 7898, BackendGatewaySetupErrorInvalidTaxOriginAddress = 7899, BackendGatewaySetupErrorMissingRequiredPermission = 7900, BackendGatewaySetupErrorSandboxModeOnly = 7901, BackendInvalidPaddleAPIKey = 7967 } /** * @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; } declare interface BuildVariablesPerPackageOptions { selectedLocale?: string; fallbackLocale?: string; customTranslations?: CustomTranslations; translator?: Translator; } /** * 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; }; } /** * Custom translations to be used in the purchase flow. * This class allows you to override the default translations used in the purchase flow. * The main level keys are the locale codes and the values are objects with the same keys as the default translations. * @public * @example * This example will override the default translation for the email step title in the English locale. * ```typescript * const customTranslations = { * en: { * "email_entry_page.email_step_title": "Billing email", * } * } * ``` */ declare type CustomTranslations = { [langKey: string]: { [translationKey in LocalizationKeys]?: string; }; }; export { CustomVariables } export { CustomVariableValue } /* Excluded from this release type: DiscountPhase */ declare type EmptyString = ""; /** * 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, TestStoreSimulatedPurchaseError = 42 } declare interface EventProperties { [key: string]: EventPropertyValue; } declare type EventPropertySingleValue = string | number | boolean; declare type EventPropertyValue = null | EventPropertySingleValue | Array<EventPropertyValue>; /* Excluded from this release type: ExpressPurchaseButtonUpdater */ /** * 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; /* Excluded from this release type: rcSource */ /* Excluded from this release type: forceEnableWalletMethods */ /** * Determines when the store module (e.g. Stripe) is loaded. * - `"configuration"`: Preloaded when the SDK is configured (default). * - `"purchase_start"`: Loaded on demand when a purchase is started. * @defaultValue "configuration" * @deprecated we always load stripe only when needed */ storeLoadTime?: StoreLoadTime; } /** * 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; /* Excluded from this release type: discountCode */ } /** * 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; /* Excluded from this release type: eventsURL */ } /** * Represents the result of an identify user operation. * @public */ export declare interface IdentifyResult { /** * The customer information after the logIn attempt. */ readonly customerInfo: CustomerInfo; /** * true if a new user has been registered in the backend, * false if the user had already been registered. */ readonly wasCreated: boolean; } declare type JsonPrimitive = string | number | boolean | null; declare type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue; }; declare class LocaleTranslations { readonly labels: Record<string, string>; readonly localeKey: string; constructor(labels: Record<string, string> | undefined, localeKey: string); private replaceVariables; translate(labelId: LocalizationKeys | EmptyString, variables?: TranslationVariables): string | undefined; translatePeriod(amount: number, period: PeriodUnit, options?: TranslatePeriodOptions): string | undefined; translatePeriodUnit(period: PeriodUnit, options?: TranslatePeriodOptions): string | undefined; translatePeriodFrequency(amount: number, period: PeriodUnit, options?: TranslateFrequencyOptions): string | undefined; translateDate(date: Date, options?: Intl.DateTimeFormatOptions): string | undefined; } declare enum LocalizationKeys { PeriodsWeek = "periods.week", PeriodsMonth = "periods.month", PeriodsYear = "periods.year", PeriodsDay = "periods.day", PeriodsWeekShort = "periods.weekShort", PeriodsMonthShort = "periods.monthShort", PeriodsYearShort = "periods.yearShort", PeriodsDayShort = "periods.dayShort", PeriodsLifetime = "periods.lifetime", PeriodsWeekPlural = "periods.weekPlural", PeriodsMonthPlural = "periods.monthPlural", PeriodsYearPlural = "periods.yearPlural", PeriodsDayPlural = "periods.dayPlural", PeriodsWeekFrequency = "periods.weekFrequency", PeriodsMonthFrequency = "periods.monthFrequency", PeriodsYearFrequency = "periods.yearFrequency", PeriodsDayFrequency = "periods.dayFrequency", PeriodsPerWeekFrequency = "periods.perWeekFrequency", PeriodsPerMonthFrequency = "periods.perMonthFrequency", PeriodsPerYearFrequency = "periods.perYearFrequency", PeriodsPerDayFrequency = "periods.perDayFrequency", PeriodsUnknownFrequency = "periods.unknownFrequency", PeriodsWeekFrequencyPlural = "periods.weekFrequencyPlural", PeriodsMonthFrequencyPlural = "periods.monthFrequencyPlural", PeriodsYearFrequencyPlural = "periods.yearFrequencyPlural", PeriodsDayFrequencyPlural = "periods.dayFrequencyPlural", ProductInfoProductTitle = "product_info.product_title", ProductInfoProductDescription = "product_info.product_description", ProductInfoProductPrice = "product_info.product_price", ProductInfoFreeTrialDuration = "product_info.free_trial_duration", ProductInfoPriceAfterFreeTrial = "product_info.price_after_free_trial", ProductInfoIntroPricePhaseAfterTrial = "product_info.intro_price_phase_after_trial", ProductInfoIntroPricePhasePaidOnce = "product_info.intro_price_phase_paid_once", ProductInfoIntroPricePhase = "product_info.intro_price_phase", ProductInfoPriceAfterIntroPrice = "product_info.price_after_intro_price", ProductInfoAfterTrial = "product_info.after_trial", ProductInfoAfter = "product_info.after", ProductInfoPriceTotalDueToday = "product_info.total_due_today", ProductInfoSubscribeTo = "product_info.subscribe_to", ProductInfoRenewalFrequency = "product_info.renewal_frequency", ProductInfoContinuesUntilCancelled = "product_info.continues_until_cancelled", ProductInfoCancelAnytime = "product_info.cancel_anytime", PaymentEntryPagePaymentStepTitle = "payment_entry_page.payment_step_title", PaymentEntryPageTrialSubscriptionTermsInfo = "payment_entry_page.trial_subscription_terms_info", PaymentEntryPageSubscriptionTermsInfo = "payment_entry_page.subscription_terms_info", PaymentEntryPageOtpTermsInfo = "payment_entry_page.otp_terms_info", PaymentEntryPageTermsLinkLabel = "payment_entry_page.terms_link_label", PaymentEntryPageSubscriptionInfo = "payment_entry_page.subscription_info", PaymentEntryPageButtonPay = "payment_entry_page.button_pay", PaymentEntryPageButtonStartTrial = "payment_entry_page.button_start_trial", PaymentEntryPageButtonWithPrice = "payment_entry_page.button_with_price", PaymentEntryPageButtonPaymentMethod = "payment_entry_page.button_payment_method", PaymentEntryPageExpressCheckoutDivider = "payment_entry_page.express_checkout_divider", SuccessPagePurchaseSuccessful = "success_page.purchase_successful", SuccessPageButtonClose = "success_page.button_close", LoadingPageProcessingPayment = "loading_page.processing_payment", LoadingPageKeepPageOpen = "loading_page.keep_page_open", ErrorPageCloseButtonTitle = "error_page.close_button_title", ErrorPageIfErrorPersists = "error_page.if_error_persists", ErrorPageTroubleAccessing = "error_page.trouble_accessing", ErrorPageErrorTitleAlreadySubscribed = "error_page.error_title_already_subscribed", ErrorPageErrorTitleAlreadyPurchased = "error_page.error_title_already_purchased", ErrorPageErrorTitleOtherErrors = "error_page.error_title_other_errors", ErrorPageErrorTitleStripeTaxNotActive = "error_page.error_title_stripe_tax_not_active", ErrorPageErrorTitleStripeInvalidTaxOriginAddress = "error_page.error_title_stripe_invalid_tax_origin_address", ErrorPageErrorTitleStripeMissingRequiredPermission = "error_page.error_title_stripe_missing_required_permission", ErrorPageErrorMessageAlreadySubscribed = "error_page.error_message_already_subscribed", ErrorPageErrorMessageAlreadyPurchased = "error_page.error_message_already_purchased", ErrorPageErrorMessageMissingEmailError = "error_page.error_message_missing_email_error", ErrorPageErrorMessageInvalidEmailError = "error_page.error_message_invalid_email_error", ErrorPageErrorMessageNetworkError = "error_page.error_message_network_error", ErrorPageErrorMessageErrorChargingPayment = "error_page.error_message_error_charging_payment", ErrorPageErrorMessageErrorSettingUpPurchase = "error_page.error_message_error_setting_up_purchase", ErrorPageErrorMessageUnknownError = "error_page.error_message_unknown_error", ErrorPageErrorMessageInvalidTaxLocation = "error_page.error_message_invalid_tax_location", ErrorPageErrorMessageStripeTaxNotActive = "error_page.error_message_stripe_tax_not_active", ErrorPageErrorMessageStripeInvalidTaxOriginAddress = "error_page.error_message_stripe_invalid_tax_origin_address", ErrorPageErrorMessageStripeMissingRequiredPermission = "error_page.error_message_stripe_missing_required_permission", ErrorPageErrorMessageOnlyInSandbox = "error_page.error_only_in_sandbox", ErrorButtonTryAgain = "error_page.button_try_again", ErrorButtonClose = "error_page.button_close", PaywallVariablesPricePerPeriod = "paywall_variables.price_per_period", PaywallVariablesSubRelativeDiscount = "paywall_variables.sub_relative_discount", PaywallVariablesTotalPriceAndPerMonth = "paywall_variables.total_price_and_per_month", PricingDropdownShowDetails = "pricing_dropdown.show_details", PricingDropdownHideDetails = "pricing_dropdown.hide_details", PricingDropdownAddPromoCode = "pricing_dropdown.add_promo_code", DiscountInputLabel = "discount_input.label", PricingTotalExcludingTax = "pricing_table.total_excluding_tax", PricingTableTrialEnds = "pricing_table.trial_ends", PricingTableTotalDueToday = "pricing_table.total_due_today", PricingTableSubtotal = "pricing_table.subtotal", PricingTableDiscount = "pricing_table.discount", PricingTableTax = "pricing_table.tax", PricingTableEnterBillingAddressToCalculate = "pricing_table.enter_billing_address_to_calculate", PricingTableEnterStateOrPostalCodeToCalculate = "pricing_table.enter_state_or_postal_code_to_calculate", PricingTableEnterPostalCodeToCalculate = "pricing_table.enter_postal_code_to_calculate", NavbarHeaderDetails = "navbar_header.details", NavbarBackButton = "navbar_header.back_button", PriceUpdateTitle = "price_update.title", PriceUpdateBaseMessage = "price_update.base_message", PriceUpdateTrialMessage = "price_update.trial_message", ApplePayFreeTrial = "apple_pay.free_trial" } /** * Custom log handler function type. Allows you to handle SDK log messages * with your own logging system. * @param logLevel - The log level of the message * @param message - The log message * @public */ export declare type LogHandler = (logLevel: LogLevel, message: string) => void; /** * 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 } /* Excluded from this release type: MetaCanonicalAttributionMetadata */ /* Excluded from this release type: MetaCapiAttributionMetadata */ /** * 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; /* Excluded from this release type: discount */ } /** * 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; /** * The default web checkout URL for this offering, if available. */ readonly webCheckoutURL?: string | 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; /** * Whether this offering has an attached paywall configured in the RevenueCat dashboard. */ readonly hasPaywall: boolean; /* Excluded from this release type: paywallComponents */ /* Excluded from this release type: uiConfig */ } /** * 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 web checkout URL for this package, if available. */ readonly webCheckoutURL?: string | null; /** * 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" } /** * Listener for paywall purchase lifecycle events. * @public */ export declare interface PaywallListener { /** * Called when a purchase flow is about to start for the given package. */ onPurchaseStarted?: (rcPackage: Package) => void; /** * Callback called when an error that won't close the paywall occurs. * For example, a retryable error during the purchase process. */ onPurchaseError?: (error: Error) => void; /** * Called when the user cancels the purchase flow. */ onPurchaseCancelled?: () => void; } /** * Represents the result of a purchase operation initiated from a paywall. * @public */ export declare interface PaywallPurchaseResult extends PurchaseResult { /** * The package selected by the customer while interacting with the paywall. */ selectedPackage: Package; } /** * 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; } /* Excluded from this release type: PresentExpressPurchaseButtonParams */ /** * Parameters for the {@link Purchases.presentPaywall} method. * @public */ export declare interface PresentPaywallParams { /** * The identifier of the offering to fetch the paywall for. * Can be a string identifier or one of the predefined keywords. */ readonly offering?: Offering; /** * The target element where the paywall will be rendered. * The paywall will create a full-screen overlay if null. */ readonly htmlTarget?: HTMLElement; /** * The target element where the checkout flow will be rendered. * The checkout flow will create a full-screen overlay if null. */ readonly purchaseHtmlTarget?: HTMLElement; /** * The email of the customer starting the purchase. * If passed the checkout flow will not ask for it to the customer. */ readonly customerEmail?: string; /** * @experimental * If set to true, the Web Billing checkout shown from the paywall * will display a discount input code field. */ readonly showDiscountCodeField?: boolean; /** * @experimental * Initial discount code to apply to the checkout when one already exists * outside of the paywall UI, for example in the hosting page's URL. */ readonly discountCode?: string; /** * @experimental * Called when the applied discount code changes in the checkout shown from * the paywall. This can be used to sync host state such as URL parameters. */ readonly onDiscountCodeChanged?: (discountCode: string | null) => void; /** * Callback to be called when the paywall tries to navigate to an external URL. * * Markdown text links keep their native browser navigation. Use this callback * for side effects or to customize how button-driven URL actions are handled. */ readonly onNavigateToUrl?: (url: string) => void; /* Excluded from this release type: onCompleteWorkflowNavigate */ /** * Callback to be called when the paywall tries to navigate back. * * Example: * ```ts * onBack: (closePaywall) => { * // You may want to keep the paywall open while showing a confirmation * // modal or logging analytics, then close it if the user confirms. * // If you want the back action to dismiss the paywall immediately, * // call closePaywall() right away. * closePaywall(); * } * ``` */ readonly onBack?: (closePaywall: () => void) => void; /** * Callback to be called when the paywall tries to visit the customer center. */ readonly onVisitCustomerCenter?: () => void; /** * Callback called when an error that won't close the paywall occurs. * For example, a retryable error during the purchase process. * @deprecated Use `listener.onPurchaseError` instead. */ readonly onPurchaseError?: (error: Error) => void; /** * Optional listener for paywall purchase lifecycle events. */ readonly listener?: PaywallListener; /** * The locale to use for the paywall and the checkout flow. */ readonly selectedLocale?: string; /** * Whether to hide back buttons in the paywall. Defaults to false. */ readonly hideBackButtons?: boolean; /** * Custom variables to pass to the paywall at runtime, overriding defaults set * in the RevenueCat dashboard. * * Variables must be defined in the dashboard first. Reference them in paywall * text using the `custom.` prefix (e.g. `{{ custom.player_name }}`). * * @example * ```ts * presentPaywall({ * customVariables: { * player_name: CustomVariableValue.string('Ada'), * level: CustomVariableValue.number(42), * is_premium: CustomVariableValue.boolean(true), * }, * }); * ``` */ readonly customVariables?: CustomVariables; } /** * 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. * @deprecated Use {@link Product.price}. */ 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; /** * Base price (after any offers) for subscriptions, price for non-subscriptions. */ readonly price: Price; /** * Base subscription duration. * Null for non-subscriptions. * Convenience accessor for the default subscription option's base phase period. */ readonly period: Period | null; /** * Free trial phase information for subscriptions. * Null for non-subscriptions or when no free trial is available. * Convenience accessor for defaultSubscriptionOption?.trial. */ readonly freeTrialPhase: PricingPhase | null; /** * Introductory price phase information for subscriptions. * Null for non-subscriptions or when no introductory price is available. * Convenience accessor for defaultSubscriptionOption?.introPrice. */ readonly introPricePhase: PricingPhase | null; /* Excluded from this release type: discountPhase */ } /** * 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" } declare class PurchaseFlowError extends Error { readonly errorCode: PurchaseFlowErrorCode; readonly underlyingErrorMessage?: string | null | undefined; readonly purchasesErrorCode?: ErrorCode | undefined; readonly extra?: PurchasesErrorExtra | undefined; readonly displayPurchaseFlowErrorCode?: boolean | undefined; constructor(errorCode: PurchaseFlowErrorCode, message?: string, underlyingErrorMessage?: string | null | undefined, purchasesErrorCode?: ErrorCode | undefined, extra?: PurchasesErrorExtra | undefined, displayPurchaseFlowErrorCode?: boolean | undefined); getErrorCode(): number; static fromPurchasesError(e: PurchasesError, defaultFlowErrorCode: PurchaseFlowErrorCode, displayPurchaseFlowErrorCode?: boolean): PurchaseFlowError; static fromBackendErrorCode(backendErrorCode: BackendErrorCode | undefined): PurchaseFlowErrorCode | null; } declare enum PurchaseFlowErrorCode { ErrorSettingUpPurchase = 0, ErrorChargingPayment = 1, UnknownError = 2, NetworkError = 3, MissingEmailError = 4, AlreadyPurchasedError = 5, StripeTaxNotActive = 6, StripeInvalidTaxOriginAddress = 7, StripeMissingRequiredPermission = 8, InvalidPaddleAPIKeyError = 9 } /** * 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; /* Excluded from this release type: workflowPurchaseContext */ /* Excluded from this release type: attributionMetadata */ /* Excluded from this release type: paywallId */ /** * 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; /** * If set to true, the SDK will skip the success page and automatically * continue the flow once the purchase completes successfully. * Defaults to `false`. */ skipSuccessPage?: boolean; /** * @experimental * If set to true, the Web Billing checkout will show a discount input code field. */ showDiscountCodeField?: boolean; /** * @experimental * Initial discount code to display as applied in the Web Billing checkout. * This is useful when the code originated outside of the checkout UI, * for example from a URL parameter. */ discountCode?: string; /** * @experimental * Called when the applied discount code changes in the Web Billing checkout. * This can be used by host applications to keep external state, such as the URL, * in sync with the checkout. */ onDiscountCodeChanged?: (discountCode: string | null) => void; /* Excluded from this release type: brandingAppearanceOverride */ /* Excluded from this release type: labelsOverride */ /* Excluded from this release type: termsAndConditionsUrl */ } /* Excluded from this release type: PurchaseResponseAttributionMetadata */ /** * 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; /** * The store transaction associated with the purchase. */ readonly storeTransaction: StoreTransaction; /* Excluded from this release type: attributionMetadata */ } /** * 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 { /* Excluded from this release type: _API_KEY */ /* Excluded from this release type: _appUserId */ /* Excluded from this release type: _brandingInfo */ /* Excluded from this release type: _loadingResourcesPromise */ /* Excluded from this release type: _flags */ /* Excluded from this release type: _context */ /* Excluded from this release type: backend */ /* Excluded from this release type: purchaseOperationHelper */ /* Excluded from this release type: eventsTracker */ /* Excluded from this release type: _platformInfo */ /* Excluded from this release type: inMemoryCache */ /* Excluded from this release type: instance */ /** * 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; /** * Set a custom log handler to handle SDK log messages with your own logging system. * If set to null, the SDK will use the default console logging. * @param handler - LogHandler function or null to use default console logging. */ static setLogHandler(handler: LogHandler | null): void; /** * Meant to be used by RevenueCat hybrids SDKS only. * @experimental * */ static setPlatformInfo(platformInfo: PlatformInfo): void; /* Excluded from this release type: buildVariablesPerPackage */ /* Excluded from this release type: getPlatformInfo */ /** * Get the singleton instance of Purchases. It's preferred to use the instance * obtained from the `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 config - Configuration object containing apiKey, appUserId, and optional configurations. * @throws {@link PurchasesError} if the API key or user id are invalid. */ static configure(config: PurchasesConfig): Purchases; /** * Legacy method to configure the Purchases SDK. This method is deprecated and will be removed in a future version. * @deprecated - please use the `configure` method with a {@link PurchasesConfig} object instead. * @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