import type { PluginListenerHandle } from "@capacitor/core"; export declare enum ATTRIBUTION_NETWORK { APPLE_SEARCH_ADS = 0, ADJUST = 1, APPSFLYER = 2, BRANCH = 3, TENJIN = 4, FACEBOOK = 5 } export declare enum PURCHASE_TYPE { /** * A type of SKU for in-app products. */ INAPP = "inapp", /** * A type of SKU for subscriptions. */ SUBS = "subs" } /** * Enum for billing features. * Currently, these are only relevant for Google Play Android users: * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType */ export declare enum BILLING_FEATURE { /** * Purchase/query for subscriptions. */ SUBSCRIPTIONS = 0, /** * Subscriptions update/replace. */ SUBSCRIPTIONS_UPDATE = 1, /** * Purchase/query for in-app items on VR. */ IN_APP_ITEMS_ON_VR = 2, /** * Purchase/query for subscriptions on VR. */ SUBSCRIPTIONS_ON_VR = 3, /** * Launch a price change confirmation flow. */ PRICE_CHANGE_CONFIRMATION = 4 } export declare enum PRORATION_MODE { UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0, /** * Replacement takes effect immediately, and the remaining time will be * prorated and credited to the user. This is the current default behavior. */ IMMEDIATE_WITH_TIME_PRORATION = 1, /** * Replacement takes effect immediately, and the billing cycle remains the * same. The price for the remaining period will be charged. This option is * only available for subscription upgrade. */ IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2, /** * Replacement takes effect immediately, and the new price will be charged on * next recurrence time. The billing cycle stays the same. */ IMMEDIATE_WITHOUT_PRORATION = 3, /** * Replacement takes effect when the old plan expires, and the new price will * be charged at the same time. */ DEFERRED = 4 } export declare enum PACKAGE_TYPE { /** * A package that was defined with a custom identifier. */ UNKNOWN = "UNKNOWN", /** * A package that was defined with a custom identifier. */ CUSTOM = "CUSTOM", /** * A package configured with the predefined lifetime identifier. */ LIFETIME = "LIFETIME", /** * A package configured with the predefined annual identifier. */ ANNUAL = "ANNUAL", /** * A package configured with the predefined six month identifier. */ SIX_MONTH = "SIX_MONTH", /** * A package configured with the predefined three month identifier. */ THREE_MONTH = "THREE_MONTH", /** * A package configured with the predefined two month identifier. */ TWO_MONTH = "TWO_MONTH", /** * A package configured with the predefined monthly identifier. */ MONTHLY = "MONTHLY", /** * A package configured with the predefined weekly identifier. */ WEEKLY = "WEEKLY" } export declare enum INTRO_ELIGIBILITY_STATUS { /** * RevenueCat doesn't have enough information to determine eligibility. */ INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0, /** * The user is not eligible for a free trial or intro pricing for this product. */ INTRO_ELIGIBILITY_STATUS_INELIGIBLE = 1, /** * The user is eligible for a free trial or intro pricing for this product. */ INTRO_ELIGIBILITY_STATUS_ELIGIBLE = 2 } /** * The EntitlementInfo object gives you access to all of the information about the status of a user entitlement. */ export interface EntitlementInfo { /** * The entitlement identifier configured in the RevenueCat dashboard */ readonly identifier: string; /** * True if the user has access to this 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 last period type this entitlement was in. Either: NORMAL, INTRO, TRIAL. */ readonly periodType: string; /** * The latest purchase or renewal date for the entitlement. */ readonly latestPurchaseDate: string; /** * The first date this entitlement was purchased. */ readonly originalPurchaseDate: string; /** * The expiration date for the entitlement, can be `null` for lifetime access. If the `periodType` is `trial`, * this is the trial expiration date. */ readonly expirationDate: string | null; /** * The store where this entitlement was unlocked from. Either: appStore, macAppStore, playStore, stripe, * promotional, unknownStore */ readonly store: string; /** * The product identifier that unlocked this entitlement */ readonly productIdentifier: string; /** * False if this entitlement is unlocked via a production purchase */ readonly isSandbox: boolean; /** * The date an unsubscribe was detected. Can be `null`. * * @note: Entitlement may still be active even if user has unsubscribed. Check the `isActive` property. */ readonly unsubscribeDetectedAt: string | 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: string | null; } /** * Contains all the entitlements associated to the user. */ export interface EntitlementInfos { /** * Map of all EntitlementInfo (`PurchasesEntitlementInfo`) objects (active and inactive) keyed by entitlement identifier. */ readonly all: { [key: string]: EntitlementInfo; }; /** * Map of active EntitlementInfo (`PurchasesEntitlementInfo`) objects keyed by entitlement identifier. */ readonly active: { [key: string]: EntitlementInfo; }; } export interface Transaction { /** * RevenueCat Id associated to the transaction. */ readonly transactionIdentifier: string; /** * Product Id associated with the transaction. */ readonly productIdentifier: string; /** * Purchase date of the transaction in ISO 8601 format. */ readonly purchaseDate: string; } export interface CustomerInfo { /** * Entitlements attached to this purchaser info */ readonly entitlements: EntitlementInfos; /** * Set of active subscription skus */ readonly activeSubscriptions: [string]; /** * Set of purchased skus, active and inactive */ readonly allPurchasedProductIdentifiers: [string]; /** * Returns all the non-subscription a user has made. * The are ordered by purchase date in ascending order. */ readonly nonSubscriptionTransactions: Transaction[]; /** * The latest expiration date of all purchased skus */ readonly latestExpirationDate: string | null; /** * The date this user was first seen in RevenueCat. */ readonly firstSeen: string; /** * The original App User Id recorded for this user. */ readonly originalAppUserId: string; /** * Date when this info was requested */ readonly requestDate: string; /** * Returns the version number for the version of the application when the * user bought the app. Use this for grandfathering users when migrating * to subscriptions. * * This corresponds to the value of CFBundleVersion (in iOS) in the * Info.plist file when the purchase was originally made. This is always null * in Android */ readonly originalApplicationVersion: string | null; /** * Returns the purchase date for the version of the application when the user bought the app. * Use this for grandfathering users when migrating to subscriptions. */ readonly originalPurchaseDate: string | null; /** * URL to manage the active subscription of the user. 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. * If there are multiple for different platforms, it will point to the device store. */ readonly managementURL: string | null; } export interface SubscriptionPeriod { /** * The Subscription Period number of unit. */ readonly numberOfUnits: number; /** * The Subscription Period unit. */ readonly unit: number; } export interface SKProductDiscount { /** * The Product discount identifier. */ readonly identifier: string; /** * The Product discount type. */ readonly type: number; /** * The Product discount price. */ readonly price: number; /** * Formatted price of the item, including its currency sign, such as €3.99. */ readonly priceString: string; /** * The Product discount currency symbol. */ readonly currencySymbol: string; /** * The Product discount currency code. */ readonly currencyCode: string; /** * The Product discount paymentMode. */ readonly paymentMode: number; /** * The Product discount number Of Periods. */ readonly numberOfPeriods: number; /** * The Product discount subscription period. */ readonly subscriptionPeriod: SubscriptionPeriod; } export interface Product { /** * Product Id. */ readonly identifier: string; /** * Description of the product. */ readonly description: string; /** * Title of the product. */ readonly title: string; /** * Price of the product in the local currency. */ readonly price: number; /** * Formatted price of the item, including its currency sign, such as €3.99. */ readonly priceString: string; /** * Currency code for price and original price. */ readonly currencyCode: string; /** * Currency symbol for price and original price. */ readonly currencySymbol: string; /** * Boolean indicating if the product is sharable with family */ readonly isFamilyShareable: boolean; /** * Group identifier for the product. */ readonly subscriptionGroupIdentifier: string; /** * The Product subcription group identifier. */ readonly subscriptionPeriod: SubscriptionPeriod; /** * The Product introductory Price. */ readonly introductoryPrice: SKProductDiscount | null; /** * The Product discounts list. */ readonly discounts: SKProductDiscount[]; } /** * Contains information about the product available for the user to purchase. * For more info see https://docs.revenuecat.com/docs/entitlements */ export interface Package { /** * Unique identifier for this package. Can be one a predefined package type or a custom one. */ readonly identifier: string; /** * Package type for the product. Will be one of [PACKAGE_TYPE]. */ readonly packageType: PACKAGE_TYPE; /** * Product assigned to this package. */ readonly product: Product; /** * Offering this package belongs to. */ readonly offeringIdentifier: string; } /** * An offering is a collection of Packages (`PurchasesPackage`) available for the user to purchase. * For more info see https://docs.revenuecat.com/docs/entitlements */ export interface Offering { /** * Unique identifier defined in RevenueCat dashboard. */ readonly identifier: string; /** * Offering description defined in RevenueCat dashboard. */ readonly serverDescription: string; /** * Array of `Package` objects 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; } /** * Contains all the offerings configured in RevenueCat dashboard. * For more info see https://docs.revenuecat.com/docs/entitlements */ export interface Offerings { /** * Map of all Offerings [PurchasesOffering] objects keyed by their identifier. */ readonly all: { [key: string]: Offering; }; /** * Current offering configured in the RevenueCat dashboard. */ readonly current: Offering | null; } export interface Error { code: number; message: string; readableErrorCode: string; underlyingErrorMessage?: string; } /** * Holds the information used when upgrading from another sku. For Android use only. */ export interface UpgradeInfo { /** * The oldSKU to upgrade from. */ readonly oldSKU: string; /** * The [PRORATION_MODE] to use when upgrading the given oldSKU. */ readonly prorationMode?: PRORATION_MODE; } /** * Holds the introductory price status */ export interface IntroEligibility { /** * The introductory price eligibility status */ readonly status: INTRO_ELIGIBILITY_STATUS; /** * Description of the status */ readonly description: string; } /** * Holds the logIn result */ export interface LogInResult { /** * The Purchaser Info for the user. */ readonly customerInfo: CustomerInfo; /** * True if the call resulted in a new user getting created in the RevenueCat backend. */ readonly created: boolean; } export type ShouldPurchasePromoProductListener = (deferredPurchase: () => void) => void; export interface CapacitorPurchasesPlugin { /** * Sets up with your API key and an app user id. * @param {string} apiKey RevenueCat API Key. Needs to be a string * @param {string} [appUserID] The unique app user id for this user. * This user id will allow users to share their purchases and subscriptions across devices. * Leave empty if you want RevenueCat to generate this for you. * @param {boolean} [observerMode = false] Set this to true if you have your own IAP implementation * @param {boolean} [enableAdServicesAttribution = false] Set this to true if you want to use Apple's Search Ads attribution collection. * @param {boolean} [collectDeviceIdentifiers = false] Set this to true if you want to collect the device identifiers. * and want to use only RevenueCat’s backend. Default is false. */ setup(data: { apiKey: string; appUserID?: string; observerMode?: boolean; enableAdServicesAttribution?: boolean; collectDeviceIdentifiers?: boolean; }): Promise; /** * Called when partialResults set to true and result received * * Provides partial result. * * @since 2.0.2 */ addListener(eventName: "purchasesUpdate", listenerFunc: (data: { purchases: Package; customerInfo: CustomerInfo; }) => void): Promise & PluginListenerHandle; /** * Gets the Offerings configured in the RevenueCat dashboard */ getOfferings(): Promise<{ offerings: Offerings; }>; /** * Make a purchase * * @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings */ purchasePackage(data: { identifier: string; offeringIdentifier: string; oldSKU?: string | null; }): Promise<{ customerInfo: CustomerInfo; }>; /** * Restores a user's previous and links their appUserIDs to any user's also using those . */ restorePurchases(): Promise<{ customerInfo: CustomerInfo; }>; /** * Subscriber attributes are useful for storing additional, structured information on a user. * Since attributes are writable using a public key they should not be used for * managing secure or sensitive information such as subscription status, coins, etc. * * Key names starting with "$" are reserved names used by RevenueCat. For a full list of key * restrictions refer to our guide: https://docs.revenuecat.com/docs/subscriber-attributes * * @param attributes Map of attributes by key. Set the value as an empty string to delete an attribute. */ setAttributes(data: { attributes: { [key: string]: string | null; }; }): Promise; /** * This function will logIn the current user with an appUserID. Typically this would be used after a log in * to identify a user without calling configure. * @param {String} appUserID The appUserID that should be linked to the currently user * @param {function(LogInResult):void} callback Callback that will receive an object that contains the customerInfo after logging in, as well as a boolean indicating * whether the user has just been created for the first time in the RevenueCat backend. * @param {function(PurchasesError):void} errorCallback Callback that will be triggered whenever there is any problem logging in. */ logIn(data: { appUserID: string; }): Promise; /** * Logs out the client clearing the saved appUserID. This will generate a random user id and save it in the cache. * If the current user is already anonymous, this will produce a Error. * @param {function(CustomerInfo):void} callback Callback that will receive the new purchaser info after resetting * @param {function(PurchasesError):void} errorCallback Callback that will be triggered whenever there is an error when logging out. * This could happen for example if logOut is called but the current user is anonymous. */ logOut(): Promise<{ customerInfo: CustomerInfo; }>; /** * Gets the current purchaser info. This call will return the cached purchaser info unless the cache is stale, in which case, * it will make a network call to retrieve it from the servers. * @param {function(CustomerInfo):void} callback Callback that will receive the purchaser info * @param {function(PurchasesError, boolean):void} errorCallback Callback that will be triggered whenever there is any problem retrieving the purchaser info */ getCustomerInfo(): Promise<{ customerInfo: CustomerInfo; }>; /** * Enables/Disables debugs logs * @param {boolean} enabled Enable or not debug logs */ setDebugLogsEnabled(data: { enabled: boolean; }): Promise; }