7.5.9 • Published 6 days ago

@revenuecat/purchases-capacitor v7.5.9

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

License Release

RevenueCat is a powerful, reliable, and free to use in-app purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy.

Whether you are building a new app or already have millions of customers, you can use RevenueCat to:

  • Fetch products, make purchases, and check subscription status with our native SDKs.
  • Host and configure products remotely from our dashboard.
  • Analyze the most important metrics for your app business in one place.
  • See customer transaction histories, chart lifetime value, and grant promotional subscriptions.
  • Get notified of real-time events through webhooks.
  • Send enriched purchase events to analytics and attribution tools with our easy integrations.

Sign up to get started for free.

@revenuecat/purchases-capacitor

@revenuecat/purchases-capacitor is the client for the RevenueCat subscription and purchase tracking system. It is an open source framework that provides a wrapper around StoreKit, Google Play Billing and the RevenueCat backend to make implementing in-app purchases in Capacitor easy.

RevenueCat SDK Features

RevenueCat
Server-side receipt validation
➡️Webhooks - enhanced server-to-server communication with events for purchases, renewals, cancellations, and more
🎯Subscription status tracking - know whether a user is subscribed whether they're on iOS, Android or web
📊Analytics - automatic calculation of metrics like conversion, mrr, and churn
📝Online documentation up to date
🔀Integrations - over a dozen integrations to easily send purchase data where you need it
💯Well maintained - frequent releases
📮Great support - Help Center

Getting Started

For more detailed information, you can view our complete documentation at docs.revenuecat.com.

Please follow the Quickstart Guide for more information on how to install the SDK.

npm install @revenuecat/purchases-capacitor
npx cap sync

Contributing

Contributions are always welcome! To learn how you can contribute, please see the Contributing Guide.

Acknowledgment

This plugin is based on CapGo's Capacitor plugin. The plugin was transferred to RevenueCat to become an officially supported plugin.

API

configure(...)

configure(configuration: PurchasesConfiguration) => Promise<void>

Sets up Purchases with your API key and an app user id.

ParamTypeDescription
configurationPurchasesConfigurationRevenueCat configuration object including the API key and other optional parameters. See {@link PurchasesConfiguration}

setMockWebResults(...)

setMockWebResults(options: { shouldMockWebResults: boolean; }) => Promise<void>

Sets whether the SDK should return mocked results in the web version. This won't affect the iOS and Android versions of the implementation. Default is false

ParamTypeDescription
options{ shouldMockWebResults: boolean; }Set shouldMockWebResults to true if you want the plugin methods to return mocked values

setFinishTransactions(...)

setFinishTransactions(options: { finishTransactions: boolean; }) => Promise<void>
ParamTypeDescription
options{ finishTransactions: boolean; }Set finishTransactions to false if you aren't using Purchases SDK to make the purchase

setSimulatesAskToBuyInSandbox(...)

setSimulatesAskToBuyInSandbox(options: { simulatesAskToBuyInSandbox: boolean; }) => Promise<void>

iOS only.

ParamTypeDescription
options{ simulatesAskToBuyInSandbox: boolean; }Set this property to true only when testing the ask-to-buy / SCA purchases flow. More information: http://errors.rev.cat/ask-to-buy

addCustomerInfoUpdateListener(...)

addCustomerInfoUpdateListener(customerInfoUpdateListener: CustomerInfoUpdateListener) => Promise<PurchasesCallbackId>

Sets a function to be called on updated customer info

ParamTypeDescription
customerInfoUpdateListenerCustomerInfoUpdateListenerCustomerInfo update listener

Returns: Promise<string>


removeCustomerInfoUpdateListener(...)

removeCustomerInfoUpdateListener(listenerToRemove: PurchasesCallbackId) => Promise<{ wasRemoved: boolean; }>

Removes a given CustomerInfoUpdateListener

ParamTypeDescription
listenerToRemovestringCustomerInfoUpdateListener reference of the listener to remove

Returns: Promise<{ wasRemoved: boolean; }>


getOfferings()

getOfferings() => Promise<PurchasesOfferings>

Gets the map of entitlements -> offerings -> products

Returns: Promise<PurchasesOfferings>


getCurrentOfferingForPlacement(...)

getCurrentOfferingForPlacement(options: { placementIdentifier: string; }) => Promise<PurchasesOffering | null>

Retrieves a current offering for a placement identifier, use this to access offerings defined by targeting placements configured in the RevenueCat dashboard.

ParamType
options{ placementIdentifier: string; }

Returns: Promise<PurchasesOffering | null>


syncAttributesAndOfferingsIfNeeded()

syncAttributesAndOfferingsIfNeeded() => Promise<PurchasesOfferings>

Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before calling this method to ensure the returned offerings are applied with the latest subscriber attributes.

Returns: Promise<PurchasesOfferings>


getProducts(...)

getProducts(options: GetProductOptions) => Promise<{ products: PurchasesStoreProduct[]; }>

Fetch the product info

ParamType
optionsGetProductOptions

Returns: Promise<{ products: PurchasesStoreProduct[]; }>


purchaseStoreProduct(...)

purchaseStoreProduct(options: PurchaseStoreProductOptions) => Promise<MakePurchaseResult>

Make a purchase

ParamType
optionsPurchaseStoreProductOptions

Returns: Promise<MakePurchaseResult>


purchaseDiscountedProduct(...)

purchaseDiscountedProduct(options: PurchaseDiscountedProductOptions) => Promise<MakePurchaseResult>

iOS only. Purchase a product applying a given discount.

ParamType
optionsPurchaseDiscountedProductOptions

Returns: Promise<MakePurchaseResult>


purchasePackage(...)

purchasePackage(options: PurchasePackageOptions) => Promise<MakePurchaseResult>

Make a purchase

ParamType
optionsPurchasePackageOptions

Returns: Promise<MakePurchaseResult>


purchaseSubscriptionOption(...)

purchaseSubscriptionOption(options: PurchaseSubscriptionOptionOptions) => Promise<MakePurchaseResult>

Google only. Make a purchase of a subscriptionOption

ParamType
optionsPurchaseSubscriptionOptionOptions

Returns: Promise<MakePurchaseResult>


purchaseDiscountedPackage(...)

purchaseDiscountedPackage(options: PurchaseDiscountedPackageOptions) => Promise<MakePurchaseResult>

iOS only. Purchase a package applying a given discount.

ParamType
optionsPurchaseDiscountedPackageOptions

Returns: Promise<MakePurchaseResult>


restorePurchases()

restorePurchases() => Promise<{ customerInfo: CustomerInfo; }>

Restores a user's previous purchases and links their appUserIDs to any user's also using those purchases.

Returns: Promise<{ customerInfo: CustomerInfo; }>


getAppUserID()

getAppUserID() => Promise<{ appUserID: string; }>

Get the appUserID

Returns: Promise<{ appUserID: string; }>


logIn(...)

logIn(options: { appUserID: string; }) => Promise<LogInResult>

This function will log in the current user with an appUserID. Typically, this would be used after a log in to identify a user without calling configure.

ParamTypeDescription
options{ appUserID: string; }The appUserID that should be linked to the current user

Returns: Promise<LogInResult>


logOut()

logOut() => Promise<{ customerInfo: CustomerInfo; }>

Logs out the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.

Returns: Promise<{ customerInfo: CustomerInfo; }>


setLogLevel(...)

setLogLevel(options: { level: LOG_LEVEL; }) => Promise<void>

Used to set the log level. Useful for debugging issues with the lovely team @RevenueCat. The default is {LOG_LEVEL.INFO} in release builds and {LOG_LEVEL.DEBUG} in debug builds.

ParamTypeDescription
options{ level: LOG_LEVEL; }Log level to use to display logs.

setLogHandler(...)

setLogHandler(logHandler: LogHandler) => Promise<void>

Set a custom log handler for redirecting logs to your own logging system. By default, this sends info, warning, and error messages. If you wish to receive Debug level messages, see setLogLevel.

ParamTypeDescription
logHandlerLogHandlerIt will get called for each log event. Use this function to redirect the log to your own logging system

getCustomerInfo()

getCustomerInfo() => Promise<{ customerInfo: CustomerInfo; }>

Gets current customer info

Returns: Promise<{ customerInfo: CustomerInfo; }>


syncPurchases()

syncPurchases() => Promise<void>

This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation for subscriptions anytime a sync is needed, like after a successful purchase.


syncObserverModeAmazonPurchase(...)

syncObserverModeAmazonPurchase(options: SyncObserverModeAmazonPurchaseOptions) => Promise<void>

This method will send a purchase to the RevenueCat backend. This function should only be called if you are in Amazon observer mode or performing a client side migration of your current users to RevenueCat.

The receipt IDs are cached if successfully posted, so they are not posted more than once.

ParamType
optionsSyncObserverModeAmazonPurchaseOptions

enableAdServicesAttributionTokenCollection()

enableAdServicesAttributionTokenCollection() => Promise<void>

Enable automatic collection of Apple Search Ad attribution on iOS. Disabled by default. Supported in iOS 14.3+ only


isAnonymous()

isAnonymous() => Promise<{ isAnonymous: boolean; }>

Returns: Promise<{ isAnonymous: boolean; }>


checkTrialOrIntroductoryPriceEligibility(...)

checkTrialOrIntroductoryPriceEligibility(options: { productIdentifiers: string[]; }) => Promise<{ [productId: string]: IntroEligibility; }>

iOS only. Computes whether a user is eligible for the introductory pricing period of a given product. You should use this method to determine whether you show the user the normal product price or the introductory price. This also applies to trials (trials are considered a type of introductory pricing).

ParamTypeDescription
options{ productIdentifiers: string[]; }Array of product identifiers for which you want to compute eligibility

Returns: Promise<{ productId: string: IntroEligibility; }>


getPromotionalOffer(...)

getPromotionalOffer(options: GetPromotionalOfferOptions) => Promise<PurchasesPromotionalOffer | undefined>

iOS only. Use this function to retrieve the PurchasesPromotionalOffer for a given PurchasesPackage.

ParamType
optionsGetPromotionalOfferOptions

Returns: Promise<PurchasesPromotionalOffer>


invalidateCustomerInfoCache()

invalidateCustomerInfoCache() => Promise<void>

Invalidates the cache for customer information.

Most apps will not need to use this method; invalidating the cache can leave your app in an invalid state. Refer to https://docs.revenuecat.com/docs/customer-info#section-get-user-information for more information on using the cache properly.

This is useful for cases where customer information might have been updated outside the app, like if a promotional subscription is granted through the RevenueCat dashboard.


presentCodeRedemptionSheet()

presentCodeRedemptionSheet() => Promise<void>

iOS 14.0+ only. Presents a code redemption sheet, useful for redeeming offer codes Refer to https://docs.revenuecat.com/docs/ios-subscription-offers#offer-codes for more information on how to configure and use offer codes


setAttributes(...)

setAttributes(attributes: { [key: string]: string | null; }) => Promise<void>

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

ParamTypeDescription
attributes{ key: string: string | null; }Map of attributes by key. Set the value as an empty string to delete an attribute.

setEmail(...)

setEmail(options: { email: string | null; }) => Promise<void>

Subscriber attribute associated with the email address for the user

ParamTypeDescription
options{ email: string | null; }Empty String or null will delete the subscriber attribute.

setPhoneNumber(...)

setPhoneNumber(options: { phoneNumber: string | null; }) => Promise<void>

Subscriber attribute associated with the phone number for the user

ParamTypeDescription
options{ phoneNumber: string | null; }Empty String or null will delete the subscriber attribute.

setDisplayName(...)

setDisplayName(options: { displayName: string | null; }) => Promise<void>

Subscriber attribute associated with the display name for the user

ParamTypeDescription
options{ displayName: string | null; }Empty String or null will delete the subscriber attribute.

setPushToken(...)

setPushToken(options: { pushToken: string | null; }) => Promise<void>

Subscriber attribute associated with the push token for the user

ParamTypeDescription
options{ pushToken: string | null; }null will delete the subscriber attribute.

setProxyURL(...)

setProxyURL(options: { url: string; }) => Promise<void>

Set this property to your proxy URL before configuring Purchases only if you've received a proxy key value from your RevenueCat contact.

ParamType
options{ url: string; }

collectDeviceIdentifiers()

collectDeviceIdentifiers() => Promise<void>

Automatically collect subscriber attributes associated with the device identifiers. $idfa, $idfv, $ip on iOS $gpsAdId, $androidId, $ip on Android


setAdjustID(...)

setAdjustID(options: { adjustID: string | null; }) => Promise<void>

Subscriber attribute associated with the Adjust ID for the user Required for the RevenueCat Adjust integration

ParamTypeDescription
options{ adjustID: string | null; }Adjust ID to use in Adjust integration. Empty String or null will delete the subscriber attribute.

setAppsflyerID(...)

setAppsflyerID(options: { appsflyerID: string | null; }) => Promise<void>

Subscriber attribute associated with the AppsFlyer ID for the user Required for the RevenueCat AppsFlyer integration

ParamTypeDescription
options{ appsflyerID: string | null; }Appsflyer ID to use in Appsflyer integration. Empty String or null will delete the subscriber attribute.

setFBAnonymousID(...)

setFBAnonymousID(options: { fbAnonymousID: string | null; }) => Promise<void>

Subscriber attribute associated with the Facebook SDK Anonymous ID for the user Recommended for the RevenueCat Facebook integration

ParamTypeDescription
options{ fbAnonymousID: string | null; }Facebook Anonymous ID to use in Mparticle integration. Empty String or null will delete the subscriber attribute.

setMparticleID(...)

setMparticleID(options: { mparticleID: string | null; }) => Promise<void>

Subscriber attribute associated with the mParticle ID for the user Recommended for the RevenueCat mParticle integration

ParamTypeDescription
options{ mparticleID: string | null; }Mparticle ID to use in Mparticle integration. Empty String or null will delete the subscriber attribute.

setCleverTapID(...)

setCleverTapID(options: { cleverTapID: string | null; }) => Promise<void>

Subscriber attribute associated with the CleverTap ID for the user Required for the RevenueCat CleverTap integration

ParamTypeDescription
options{ cleverTapID: string | null; }CleverTap user ID to use in CleverTap integration. Empty String or null will delete the subscriber attribute.

setMixpanelDistinctID(...)

setMixpanelDistinctID(options: { mixpanelDistinctID: string | null; }) => Promise<void>

Subscriber attribute associated with the Mixpanel Distinct ID for the user Required for the RevenueCat Mixpanel integration

ParamTypeDescription
options{ mixpanelDistinctID: string | null; }Mixpanel Distinct ID to use in Mixpanel integration. Empty String or null will delete the subscriber attribute.

setFirebaseAppInstanceID(...)

setFirebaseAppInstanceID(options: { firebaseAppInstanceID: string | null; }) => Promise<void>

Subscriber attribute associated with the Firebase App Instance ID for the user Required for the RevenueCat Firebase integration

ParamTypeDescription
options{ firebaseAppInstanceID: string | null; }Firebase App Instance ID to use in Firebase integration. Empty String or null will delete the subscriber attribute.

setOnesignalID(...)

setOnesignalID(options: { onesignalID: string | null; }) => Promise<void>

Subscriber attribute associated with the OneSignal Player ID for the user Required for the RevenueCat OneSignal integration

ParamTypeDescription
options{ onesignalID: string | null; }OneSignal Player ID to use in OneSignal integration. Empty String or null will delete the subscriber attribute.

setAirshipChannelID(...)

setAirshipChannelID(options: { airshipChannelID: string | null; }) => Promise<void>

Subscriber attribute associated with the Airship Channel ID for the user Required for the RevenueCat Airship integration

ParamTypeDescription
options{ airshipChannelID: string | null; }Airship Channel ID to use in Airship integration. Empty String or null will delete the subscriber attribute.

setMediaSource(...)

setMediaSource(options: { mediaSource: string | null; }) => Promise<void>

Subscriber attribute associated with the install media source for the user

ParamTypeDescription
options{ mediaSource: string | null; }Empty String or null will delete the subscriber attribute.

setCampaign(...)

setCampaign(options: { campaign: string | null; }) => Promise<void>

Subscriber attribute associated with the install campaign for the user

ParamTypeDescription
options{ campaign: string | null; }Empty String or null will delete the subscriber attribute.

setAdGroup(...)

setAdGroup(options: { adGroup: string | null; }) => Promise<void>

Subscriber attribute associated with the install ad group for the user

ParamTypeDescription
options{ adGroup: string | null; }Empty String or null will delete the subscriber attribute.

setAd(...)

setAd(options: { ad: string | null; }) => Promise<void>

Subscriber attribute associated with the install ad for the user

ParamTypeDescription
options{ ad: string | null; }Empty String or null will delete the subscriber attribute.

setKeyword(...)

setKeyword(options: { keyword: string | null; }) => Promise<void>

Subscriber attribute associated with the install keyword for the user

ParamTypeDescription
options{ keyword: string | null; }Empty String or null will delete the subscriber attribute.

setCreative(...)

setCreative(options: { creative: string | null; }) => Promise<void>

Subscriber attribute associated with the install ad creative for the user

ParamTypeDescription
options{ creative: string | null; }Empty String or null will delete the subscriber attribute.

canMakePayments(...)

canMakePayments(options?: { features?: BILLING_FEATURE[] | undefined; } | undefined) => Promise<{ canMakePayments: boolean; }>

Check if billing is supported for the current user (meaning IN-APP purchases are supported) and optionally, whether a list of specified feature types are supported.

Note: Billing features are only relevant to Google Play Android users. For other stores and platforms, billing features won't be checked.

ParamTypeDescription
options{ features?: BILLING_FEATURE[]; }An array of feature types to check for support. Feature types must be one of BILLING_FEATURE. By default, is an empty list and no specific feature support will be checked.

Returns: Promise<{ canMakePayments: boolean; }>


beginRefundRequestForActiveEntitlement()

beginRefundRequestForActiveEntitlement() => Promise<{ refundRequestStatus: REFUND_REQUEST_STATUS; }>

iOS 15+ only. Presents a refund request sheet in the current window scene for the latest transaction associated with the active entitlement.

If the request was unsuccessful, no active entitlements could be found for the user, or multiple active entitlements were found for the user, the promise will return an error. If called in an unsupported platform (Android or iOS < 15), an UnsupportedPlatformException will be thrown.

Important: This method should only be used if your user can only have a single active entitlement at a given time. If a user could have more than one entitlement at a time, use beginRefundRequestForEntitlement instead.

Returns: Promise<{ refundRequestStatus: REFUND_REQUEST_STATUS; }>


beginRefundRequestForEntitlement(...)

beginRefundRequestForEntitlement(options: { entitlementInfo: PurchasesEntitlementInfo; }) => Promise<{ refundRequestStatus: REFUND_REQUEST_STATUS; }>

iOS 15+ only. Presents a refund request sheet in the current window scene for the latest transaction associated with the entitlement.

If the request was unsuccessful, the promise will return an error. If called in an unsupported platform (Android or iOS < 15), an UnsupportedPlatformException will be thrown.

ParamTypeDescription
options{ entitlementInfo: PurchasesEntitlementInfo; }The entitlement to begin a refund request for.

Returns: Promise<{ refundRequestStatus: REFUND_REQUEST_STATUS; }>


beginRefundRequestForProduct(...)

beginRefundRequestForProduct(options: { storeProduct: PurchasesStoreProduct; }) => Promise<{ refundRequestStatus: REFUND_REQUEST_STATUS; }>

iOS 15+ only. Presents a refund request sheet in the current window scene for the latest transaction associated with the product.

If the request was unsuccessful, the promise will return an error. If called in an unsupported platform (Android or iOS < 15), an UnsupportedPlatformException will be thrown.

ParamTypeDescription
options{ storeProduct: PurchasesStoreProduct; }The StoreProduct to begin a refund request for.

Returns: Promise<{ refundRequestStatus: REFUND_REQUEST_STATUS; }>


showInAppMessages(...)

showInAppMessages(options?: { messageTypes?: IN_APP_MESSAGE_TYPE[] | undefined; } | undefined) => Promise<void>

Shows in-app messages available from the App Store or Google Play. You need to disable messages from showing automatically using PurchasesConfiguration.shouldShowInAppMessagesAutomatically.

Note: In iOS, this requires version 16+. In older versions the promise will be resolved successfully immediately.

ParamTypeDescription
options{ messageTypes?: IN_APP_MESSAGE_TYPE[]; }An array of message types that the stores can display inside your app. Values must be one of IN_APP_MESSAGE_TYPE. By default, is undefined and all message types will be shown.

isConfigured()

isConfigured() => Promise<{ isConfigured: boolean; }>

Check if configure has finished and Purchases has been configured.

Returns: Promise<{ isConfigured: boolean; }>


Interfaces

PurchasesConfiguration

Holds parameters to initialize the SDK.

PropTypeDescription
apiKeystringRevenueCat API Key. Needs to be a string
appUserIDstring | nullA unique id for identifying the user
observerModebooleanAn optional boolean. Set this to TRUE if you have your own IAP implementation and want to use only RevenueCat's backend. Default is FALSE. If you are on Android and setting this to ON, you will have to acknowledge the purchases yourself.
userDefaultsSuiteNamestringAn optional string. iOS-only, will be ignored for Android. Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults. Default is null, which will make the SDK use standardUserDefaults.
usesStoreKit2IfAvailablebooleaniOS-only, will be ignored for Android. Set this to TRUE to enable StoreKit2. Default is FALSE.
useAmazonbooleanAn optional boolean. Android only. Required to configure the plugin to be used in the Amazon Appstore.
shouldShowInAppMessagesAutomaticallybooleanWhether we should show store in-app messages automatically. Both Google Play and the App Store provide in-app messages for some situations like billing issues. By default, those messages will be shown automatically. This allows to disable that behavior, so you can display those messages at your convenience. For more information, check: https://rev.cat/storekit-message and https://rev.cat/googleplayinappmessaging
entitlementVerificationModeENTITLEMENT_VERIFICATION_MODEVerification strictness levels for EntitlementInfo. See https://rev.cat/trusted-entitlements for more info.

CustomerInfo

PropTypeDescription
entitlementsPurchasesEntitlementInfosEntitlements attached to this customer info
activeSubscriptionsstring[]Set of active subscription skus
allPurchasedProductIdentifiersstring[]Set of purchased skus, active and inactive
latestExpirationDatestring | nullThe latest expiration date of all purchased skus
firstSeenstringThe date this user was first seen in RevenueCat.
originalAppUserIdstringThe original App User Id recorded for this user.
requestDatestringDate when this info was requested
allExpirationDates{ key: string: string | null; }Map of skus to expiration dates
allPurchaseDates{ key: string: string | null; }Map of skus to purchase dates
originalApplicationVersionstring | nullReturns 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
originalPurchaseDatestring | nullReturns the purchase date for the version of the application when the user bought the app. Use this for grandfathering users when migrating to subscriptions.
managementURLstring | nullURL 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.
nonSubscriptionTransactionsPurchasesStoreTransaction[]

PurchasesEntitlementInfos

Contains all the entitlements associated to the user.

PropTypeDescription
all{ key: string: PurchasesEntitlementInfo; }Map of all EntitlementInfo (PurchasesEntitlementInfo) objects (active and inactive) keyed by entitlement identifier.
active{ key: string: PurchasesEntitlementInfo; }Map of active EntitlementInfo (PurchasesEntitlementInfo) objects keyed by entitlement identifier.
verificationVERIFICATION_RESULTIf entitlement verification was enabled, the result of that verification. If not, VerificationResult.NOT_REQUESTED

PurchasesEntitlementInfo

The EntitlementInfo object gives you access to all of the information about the status of a user entitlement.

PropTypeDescription
identifierstringThe entitlement identifier configured in the RevenueCat dashboard
isActivebooleanTrue if the user has access to this entitlement
willRenewbooleanTrue if the underlying subscription is set to renew at the end of the billing period (expirationDate).
periodTypestringThe last period type this entitlement was in. Either: NORMAL, INTRO, TRIAL.
latestPurchaseDatestringThe latest purchase or renewal date for the entitlement in ISO8601 format.
latestPurchaseDateMillisnumberThe latest purchase or renewal date for the entitlement in milliseconds.
originalPurchaseDatestringThe first date this entitlement was purchased in ISO8601 format.
originalPurchaseDateMillisnumberThe first date this entitlement was purchased in milliseconds.
expirationDatestring | nullThe expiration date for the entitlement in ISO8601, can be null for lifetime access. If the periodType is trial, this is the trial expiration date.
expirationDateMillisnumber | nullThe expiration date for the entitlement in milliseconds, can be null for lifetime access. If the periodType is trial, this is the trial expiration date.
store'PLAY_STORE' | 'APP_STORE' | 'STRIPE' | 'MAC_APP_STORE' | 'PROMOTIONAL' | 'AMAZON' | 'RC_BILLING' | 'EXTERNAL' | 'UNKNOWN_STORE'The store where this entitlement was unlocked from.
productIdentifierstringThe product identifier that unlocked this entitlement
productPlanIdentifierstring | nullThe product plan identifier that unlocked this entitlement. Android subscriptions only, null on consumables and iOS.
isSandboxbooleanFalse if this entitlement is unlocked via a production purchase
unsubscribeDetectedAtstring | nullThe date an unsubscribe was detected in ISO8601 format. Can be null.
unsubscribeDetectedAtMillisnumber | nullThe date an unsubscribe was detected in milliseconds. Can be null.
billingIssueDetectedAtstring | nullThe date a billing issue was detected in ISO8601 format. Can be null if there is no billing issue or an issue has been resolved
billingIssueDetectedAtMillisnumber | nullThe date a billing issue was detected in milliseconds. Can be null if there is no billing issue or an issue has been resolved
ownershipType'FAMILY_SHARED' | 'PURCHASED' | 'UNKNOWN'Supported ownership types for an entitlement. PURCHASED if the purchase was made directly by this user. FAMILY_SHARED if the purchase has been shared to this user by a family member. UNKNOWN if the purchase has no or an unknown ownership type.
verificationVERIFICATION_RESULTIf entitlement verification was enabled, the result of that verification. If not, VerificationResult.NOT_REQUESTED

PurchasesStoreTransaction

List of all non subscription transactions. Use this to fetch the history of non-subscription purchases

PropTypeDescription
transactionIdentifierstringId of the transaction.
productIdentifierstringProduct Id associated with the transaction.
purchaseDatestringPurchase date of the transaction in ISO 8601 format.

PurchasesOfferings

Contains all the offerings configured in RevenueCat dashboard. For more info see https://docs.revenuecat.com/docs/entitlements

PropTypeDescription
all{ key: string: PurchasesOffering; }Map of all Offerings PurchasesOffering objects keyed by their identifier.
currentPurchasesOffering | nullCurrent offering configured in the RevenueCat dashboard.

PurchasesOffering

An offering is a collection of Packages (PurchasesPackage) available for the user to purchase. For more info see https://docs.revenuecat.com/docs/entitlements

PropTypeDescription
identifierstringUnique identifier defined in RevenueCat dashboard.
serverDescriptionstringOffering description defined in RevenueCat dashboard.
metadata{ key: string: unknown; }Offering metadata defined in RevenueCat dashboard. To access values, you need to check the type beforehand. For example: const my_unknown_value: unknown = offering.metadata'my_key'; const my_string_value: string | undefined = typeof(my_unknown_value) === 'string' ? my_unknown_value : undefined;
availablePackagesPurchasesPackage[]Array of Package objects available for purchase.
lifetimePurchasesPackage | nullLifetime package type configured in the RevenueCat dashboard, if available.
annualPurchasesPackage | nullAnnual package type configured in the RevenueCat dashboard, if available.
sixMonthPurchasesPackage | nullSix month package type configured in the RevenueCat dashboard, if available.
threeMonthPurchasesPackage | nullThree month package type configured in the RevenueCat dashboard, if available.
twoMonthPurchasesPackage | nullTwo month package type configured in the RevenueCat dashboard, if available.
monthlyPurchasesPackage | nullMonthly package type configured in the RevenueCat dashboard, if available.
weeklyPurchasesPackage | nullWeekly package type configured in the RevenueCat dashboard, if available.

PurchasesPackage

Contains information about the product available for the user to purchase. For more info see https://docs.revenuecat.com/docs/entitlements

PropTypeDescription
identifierstringUnique identifier for this package. Can be one a predefined package type or a custom one.
packageTypePACKAGE_TYPEPackage type for the product. Will be one of PACKAGE_TYPE.
productPurchasesStoreProductProduct assigned to this package.
offeringIdentifierstringOffering this package belongs to.
presentedOfferingContextPresentedOfferingContextOffering context this package belongs to. Null if not using offerings or if fetched directly from store via getProducts.

PurchasesStoreProduct

PropTypeDescription
identifierstringProduct Id.
descriptionstringDescription of the product.
titlestringTitle of the product.
pricenumberPrice of the product in the local currency. Contains the price value of defaultOption for Google Play.
priceStringstringFormatted price of the item, including its currency sign. Contains the formatted price value of defaultOption for Google Play.
currencyCodestringCurrency code for price and original price. Contains the currency code value of defaultOption for Google Play.
introPricePurchasesIntroPrice | nullIntroductory price.
discountsPurchasesStoreProductDiscount[] | nullCollection of discount offers for a product. Null for Android.
productCategoryPRODUCT_CATEGORY | nullProduct category.
productTypePRODUCT_TYPEThe specific type of subscription or one time purchase this product represents. Important: In iOS, if using StoreKit 1, we cannot determine the type.
subscriptionPeriodstring | nullSubscription period, specified in ISO 8601 format. For example, P1W equates to one week, P1M equates to one month, P3M equates to three months, P6M equates to six months, and P1Y equates to one year. Note: Not available for Amazon.
defaultOptionSubscriptionOption | nullDefault subscription option for a product. Google Play only.
subscriptionOptionsSubscriptionOption[] | nullCollection of subscription options for a product. Google Play only.
presentedOfferingIdentifierstring | nullOffering identifier the store product was presented from. Null if not using offerings or if fetched directly from store via getProducts.
presentedOfferingContextPresentedOfferingContext | nullOffering context this package belongs to. Null if not using offerings or if fetched directly from store via getProducts.

PurchasesIntroPrice

PropTypeDescription
pricenumberPrice in the local currency.
priceStringstringFormatted price, including its currency sign, such as €3.99.
cyclesnumberNumber of subscription billing periods for which the user will be given the discount, such as 3.
periodstringBilling period of the discount, specified in ISO 8601 format.
periodUnitstringUnit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
periodNumberOfUnitsnumberNumber of units for the billing period of the discount.

PurchasesStoreProductDiscount

PropTypeDescription
identifierstringIdentifier of the discount.
pricenumberPrice in the local currency.
priceStringstringFormatted price, including its currency sign, such as €3.99.
cyclesnumberNumber of subscription billing periods for which the user will be given the discount, such as 3.
periodstringBilling period of the discount, specified in ISO 8601 format.
periodUnitstringUnit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
periodNumberOfUnitsnumberNumber of units for the billing period of the discount.

SubscriptionOption

Contains all details associated with a SubscriptionOption Used only for Google

PropTypeDescription
idstringIdentifier of the subscription option If this SubscriptionOption represents a base plan, this will be the basePlanId. If it represents an offer, it will be {basePlanId}:{offerId}
storeProductIdstringIdentifier of the StoreProduct associated with this SubscriptionOption This will be {subId}:{basePlanId}
productIdstringIdentifer of the subscription associated with this SubscriptionOption This will be {subId}
pricingPhasesPricingPhase[]Pricing phases defining a user's payment plan for the product over time.
tagsstring[]Tags defined on the base plan or offer. Empty for Amazon.
isBasePlanbooleanTrue if this SubscriptionOption represents a subscription base plan (rather than an offer).
billingPeriodPeriod | nullThe subscription period of fullPricePhase (after free and intro trials).
isPrepaidbooleanTrue if the subscription is pre-paid.
fullPricePhasePricingPhase | nullThe full price PricingPhase of the subscription. Looks for the last price phase of the SubscriptionOption.
freePhasePricingPhase | nullThe free trial PricingPhase of the subscription. Looks for the first pricing phase of the SubscriptionOption where amountMicros is 0. There can be a freeTrialPhase and an introductoryPhase in the same SubscriptionOption.
introPhasePricingPhase | nullThe intro trial PricingPhase of the subscription. Looks for the first pricing phase of the SubscriptionOption where amountMicros is greater than 0. There can be a freeTrialPhase and an introductoryPhase in the same SubscriptionOption.
presentedOfferingIdentifierstring | nullOffering identifier the subscription option was presented from
presentedOfferingContextPresentedOfferingContext | nullOffering context this package belongs to. Null if not using offerings or if fetched directly from store via getProducts.

PricingPhase

Contains all the details associated with a PricingPhase

PropTypeDescription
billingPeriodPeriodBilling period for which the PricingPhase applies
recurrenceModeRECURRENCE_MODE | nullRecurrence mode of the PricingPhase
billingCycleCountnumber | nullNumber of cycles for which the pricing phase applies. Null for infiniteRecurring or finiteRecurring recurrence modes.
pricePricePrice of the PricingPhase
offerPaymentModeOFFER_PAYMENT_MODE | nullIndicates how the pricing phase is charged for finiteRecurring pricing phases

Period

Contains all the details associated with a Period

PropTypeDescription
unitPERIOD_UNITThe number of period units: day, week, month, year, unknown
valuenumberThe increment of time that a subscription period is specified in
iso8601stringSpecified in ISO 8601 format. For example, P1W equates to one week, P1M equates to one month, P3M equates to three months, P6M equates to six months, and P1Y equates to one year

Price

Contains all the details associated with a Price

PropTypeDescription
formattedstringFormatted price of the item, including its currency sign. For example $3.00
amountMicrosnumberPrice in micro-units, where 1,000,000 micro-units equal one unit of the currency. For example, if price is "€7.99", price_amount_micros is 7,990,000. This value represents the localized, rounded price for a particular currency.
currencyCodestringReturns ISO 4217 currency code for price and original price. For example, if price is specified in British pounds sterling, price_currency_code is "GBP". If currency code cannot be determined, currency symbol is returned.

PresentedOfferingContext

Contains data about the context in which an offering was presented.

PropTypeDescription
offeringIdentifierstringThe identifier of the offering used to obtain this object.
placementIdentifierstring | nullThe identifier of the placement used to obtain this object.
targetingContextPresentedOfferingTargetingContext | nullThe revision of the targeting used to obtain this object.

PresentedOfferingTargetingContext

Contains data about the context in which an offering was presented.

PropTypeDescription
revisionnumberThe revision of the targeting used to obtain this object.
ruleIdstringThe rule id from the targeting used to obtain this object.

GetProductOptions

PropTypeDescription
productIdentifiersstring[]Array of product identifiers to obtain
typePRODUCT_CATEGORYOptional type of products to fetch, can be SUBSCRIPTION or NON_SUBSCRIPTION. SUBSCRIPTION by default. Ignored in iOS.

PurchaseStoreProductOptions

PropTypeDescription
productPurchasesStoreProductThe product you want to purchase
googleProductChangeInfoGoogleProductChangeInfo | nullAndroid only. Optional GoogleProductChangeInfo you wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
googleIsPersonalizedPriceboolean | nullAndroid and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customized for you" in the purchase dialog when true. See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.

GoogleProductChangeInfo

Holds the information used when upgrading from another sku. For Android use only.

PropTypeDescription
oldProductIdentifierstringThe old product identifier to upgrade from.
prorationModePRORATION_MODEThe PRORATION_MODE to use when upgrading the given oldSKU.

PurchaseDiscountedProductOptions

PropTypeDescription
productPurchasesStoreProductThe product you want to purchase
discountPurchasesPromotionalOfferDiscount to apply to this package. Retrieve this discount using getPromotionalOffer.

PurchasesPromotionalOffer

PropType
identifierstring
keyIdentifierstring
noncestring
signaturestring
timestampnumber

PurchasePackageOptions

PropTypeDescription
aPackagePurchasesPackageThe Package you wish to purchase. You can get the Packages by calling getOfferings
googleProductChangeInfoGoogleProductChangeInfo | nullAndroid only. Optional GoogleProductChangeInfo you wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
googleIsPersonalizedPriceboolean | nullAndroid and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customized for you" in the purchase dialog when true. See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.

PurchaseSubscriptionOptionOptions

PropTypeDescription
subscriptionOptionSubscriptionOptionThe SubscriptionOption you wish to purchase. You can get the SubscriptionOption from StoreProducts by calling getOfferings
googleProductChangeInfoGoogleProductChangeInfo | nullAndroid only. Optional GoogleProductChangeInfo you wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
googleIsPersonalizedPriceboolean | nullAndroid and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customized for you" in the purchase dialog when true. See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.

PurchaseDiscountedPackageOptions

PropTypeDescription
aPackagePurchasesPackageThe Package you wish to purchase. You can get the Packages by calling getOfferings
discountPurchasesPromotionalOfferDiscount to apply to this package. Retrieve this discount using getPromotionalOffer.

LogInResult

Holds the logIn result

PropTypeDescription
customerInfoCustomerInfoThe Customer Info for the user.
createdbooleanTrue if the call resulted in a new user getting created in the RevenueCat backend.

SyncObserverModeAmazonPurchaseOptions

PropTypeDescription
productIDstringProduct ID associated to the purchase.
receiptIDstringReceiptId that represents the Amazon purchase.
amazonUserIDstringAmazon's userID. This parameter will be ignored when syncing a Google purchase.
isoCurrencyCodestring | nullProduct's currency code in ISO 4217 format.
pricenumber | nullProduct's price.

IntroEligibility

Holds the introductory price status

PropTypeDescription
statusINTRO_ELIGIBILITY_STATUSThe introductory price eligibility status
descriptionstringDescription of the status

GetPromotionalOfferOptions

PropTypeDescription
productPurchasesStoreProductThe PurchasesStoreProduct the user intends to purchase.
discountPurchasesStoreProductDiscountThe PurchasesStoreProductDiscount to apply to the product.

Type Aliases

CustomerInfoUpdateListener

Listener used on updated customer info

(customerInfo: CustomerInfo): void

PurchasesCallbackId

string

MakePurchaseResult

{ productIdentifier: string; customerInfo: CustomerInfo; transaction: PurchasesStoreTransaction; }

LogHandler

(logLevel: LOG_LEVEL, message: string): void

Enums

ENTITLEMENT_VERIFICATION_MODE

MembersValueDescription
DISABLED"DISABLED"The SDK will not perform any entitlement verification.
INFORMATIONAL"INFORMATIONAL"Enable entitlement verification. If verification fails, this will be indicated with VerificationResult.FAILED in the EntitlementInfos.verification and EntitlementInfo.verification properties but parsing will not fail (i.e. Entitlements will still be granted). This can be useful if you want to handle verification failures to display an error/warning to the user or to track this situation but still grant access.

VERIFICATION_RESULT

MembersValueDescription
NOT_REQUESTED"NOT_REQUESTED"No verification was done. This value is returned when verification is not enabled in PurchasesConfiguration
VERIFIED"VERIFIED"Verification with our server was performed successfully.
FAILED"FAILED"Verification failed, possibly due to a MiTM attack.
VERIFIED_ON_DEVICE"VERIFIED_ON_DEVICE"Verification was performed on device.

PACKAGE_TYPE

MembersValueDescription
UNKNOWN"UNKNOWN"A package that was defined with a custom identifier.
CUSTOM"CUSTOM"A package that was defined with a custom identifier.
LIFETIME"LIFETIME"A package configured with the predefined lifetime identifier.
ANNUAL"ANNUAL"A package configured with the predefined annual identifier.
SIX_MONTH"SIX_MONTH"A package configured with the predefined six month identifier.
THREE_MONTH"THREE_MONTH"A package configured with the predefined three month identifier.
TWO_MONTH"TWO_MONTH"A package configured with the predefined two month identifier.
MONTHLY"MONTHLY"A package configured with the predefined monthly identifier.
WEEKLY"WEEKLY"A package configured with the predefined weekly identifier.

PRODUCT_CATEGORY

MembersValueDescription
NON_SUBSCRIPTION"NON_SUBSCRIPTION"A type of product for non-subscription.
SUBSCRIPTION"SUBSCRIPTION"A type of product for subscriptions.
UNKNOWN"UNKNOWN"A type of product for unknowns.

PRODUCT_TYPE

MembersValueDescription
CONSUMABLE"CONSUMABLE"A consumable in-app purchase.
NON_CONSUMABLE"NON_CONSUMABLE"A non-consumable in-app purchase. Only applies to Apple Store products.
NON_RENEWABLE_SUBSCRIPTION"NON_RENEWABLE_SUBSCRIPTION"A non-renewing subscription. Only applies to Apple Store products.
AUTO_RENEWABLE_SUBSCRIPTION"AUTO_RENEWABLE_SUBSCRIPTION"An auto-renewable subscription.
PREPAID_SUBSCRIPTION"PREPAID_SUBSCRIPTION"A subscription that is pre-paid. Only applies to Google Play products.
UNKNOWN"UNKNOWN"Unable to determine product type.

PERIOD_UNIT

MembersValue
DAY"DAY"
WEEK"WEEK"
MONTH"MONTH"
YEAR"YEAR"
UNKNOWN"UNKNOWN"

RECURRENCE_MODE

MembersValueDescription
INFINITE_RECURRING1Pricing phase repeats infinitely until cancellation
FINITE_RECURRING2Pricing phase repeats for a fixed number of billing periods
NON_RECURRING3Pricing phase does not repeat

OFFER_PAYMENT_MODE

MembersValueDescription
FREE_TRIAL"FREE_TRIAL"Subscribers don't pay until the specified period ends
SINGLE_PAYMENT"SINGLE_PAYMENT"Subscribers pay up front for a specified period
DISCOUNTED_RECURRING_PAYMENT"DISCOUNTED_RECURRING_PAYMENT"Subscribers pay a discounted amount for a specified number of periods

PRORATION_MODE

MembersValueDescription
UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY0
IMMEDIATE_WITH_TIME_PRORATION1Replacement takes effect immediately, and the remaining time will be prorated and credited to the user. This is the current default behavior.
IMMEDIATE_AND_CHARGE_PRORATED_PRICE2Replacement 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_WITHOUT_PRORATION3Replacement takes effect immediately, and the new price will be charged on next recurrence time. The billing cycle stays the same.
IMMEDIATE_AND_CHARGE_FULL_PRICE5Replacement takes effect immediately, and the user is charged full price of new plan and is given a full billing cycle of subscription, plus remaining prorated time from the old plan.

LOG_LEVEL

MembersValue
VERBOSE"VERBOSE"
DEBUG"DEBUG"
INFO"INFO"
WARN"WARN"
ERROR"ERROR"

INTRO_ELIGIBILITY_STATUS

MembersValueDescription
INTRO_ELIGIBILITY_STATUS_UNKNOWN0RevenueCat doesn't have enough information to determine eligibility.
INTRO_ELIGIBILITY_STATUS_INELIGIBLE1The user is not eligible for a free trial or intro pricing for this product.
INTRO_ELIGIBILITY_STATUS_ELIGIBLE2The user is eligible for a free trial or intro pricing for this product.
INTRO_ELIGIBILITY_STATUS_NO_INTRO_OFFER_EXISTS3There is no free trial or intro pricing for this product.

BILLING_FEATURE

MembersValueDescription
SUBSCRIPTIONS0Purchase/query for subscriptions.
SUBSCRIPTIONS_UPDATE1Subscriptions update/replace.
IN_APP_ITEMS_ON_VR2Purchase/query for in-app items on VR.
SUBSCRIPTIONS_ON_VR3Purchase/query for subscriptions on VR.
PRICE_CHANGE_CONFIRMATION4Launch a price change confirmation flow.

REFUND_REQUEST_STATUS

MembersValueDescription
SUCCESS0Apple has received the refund request.
USER_CANCELLED1User canceled submission of the refund request.
ERROR2There was an error with the request. See message for more details.

IN_APP_MESSAGE_TYPE

MembersValueDescription
BILLING_ISSUE0In-app messages to indicate there has been a billing issue charging the user.
PRICE_INCREASE_CONSENT1iOS-only. This message will show if you increase the price of a subscription and the user needs to opt-in to the increase.
GENERIC2iOS-only. StoreKit generic messages.
8.0.0-beta.2

6 days ago

7.5.9

12 days ago

8.0.0-beta.1

23 days ago

7.5.8

24 days ago

7.5.7

1 month ago

7.5.6

1 month ago

7.5.5

2 months ago

6.1.2

2 months ago

7.5.4

2 months ago

7.5.3

2 months ago

7.5.2

3 months ago

7.5.1

3 months ago

6.1.1

3 months ago

7.5.0

3 months ago

7.4.0

4 months ago

7.3.2

5 months ago

7.3.1

5 months ago

7.3.0

5 months ago

7.2.0

6 months ago

7.1.1

6 months ago

7.1.0

6 months ago

7.0.0

7 months ago

6.1.0

7 months ago

6.0.0

8 months ago

6.0.0-beta.2

8 months ago

6.0.0-beta.1

9 months ago