Socket
Socket
Sign inDemoInstall

capacitor-purchases

Package Overview
Dependencies
2
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    capacitor-purchases

In-app Subscriptions Made Easy with RevenueCat sdk


Version published
Weekly downloads
3
decreased by-93.18%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

capacitor-purchases

In-app Subscriptions Made Easy with RevenueCat sdk

Capacitor implementation with new RevenueCat swift SDK v4

Install

npm install capacitor-purchases
npx cap sync

API

setup(...)

setup(data: { apiKey: string; }) => Promise<void>

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

ParamType
data{ apiKey: string; }

addListener('purchasesUpdate', ...)

addListener(eventName: "purchasesUpdate", listenerFunc: (data: { purchases: Package; purchaserInfo: PurchaserInfo; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when partialResults set to true and result received

Provides partial result.

ParamType
eventName'purchasesUpdate'
listenerFunc(data: { purchases: Package; purchaserInfo: PurchaserInfo; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 2.0.2


getOfferings()

getOfferings() => Promise<{ offerings: Offerings; }>

Gets the Offerings configured in the RevenueCat dashboard

Returns: Promise<{ offerings: Offerings; }>


purchasePackage(...)

purchasePackage(data: { identifier: string; offeringIdentifier: string; }) => Promise<{ purchaserInfo: PurchaserInfo; }>

Make a purchase

ParamType
data{ identifier: string; offeringIdentifier: string; }

Returns: Promise<{ purchaserInfo: PurchaserInfo; }>


restoreTransactions()

restoreTransactions() => Promise<{ purchaserInfo: PurchaserInfo; }>

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

Returns: Promise<{ purchaserInfo: PurchaserInfo; }>


setAttributes(...)

setAttributes(data: { 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

ParamType
data{ attributes: { [key: string]: string | null; }; }

logIn(...)

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

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.

ParamType
data{ appUserID: string; }

Returns: Promise<LogInResult>


logOut()

logOut() => Promise<{ purchaserInfo: PurchaserInfo; }>

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.

Returns: Promise<{ purchaserInfo: PurchaserInfo; }>


getPurchaserInfo()

getPurchaserInfo() => Promise<{ purchaserInfo: PurchaserInfo; }>

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.

Returns: Promise<{ purchaserInfo: PurchaserInfo; }>


setDebugLogsEnabled(...)

setDebugLogsEnabled(data: { enabled: boolean; }) => Promise<void>

Enables/Disables debugs logs

ParamType
data{ enabled: boolean; }

Interfaces

PluginListenerHandle
PropType
remove() => Promise<void>
Package

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].
productProductProduct assigned to this package.
offeringIdentifierstringOffering this package belongs to.
Product
PropTypeDescription
identifierstringProduct Id.
descriptionstringDescription of the product.
titlestringTitle of the product.
pricenumberPrice of the product in the local currency.
priceStringstringFormatted price of the item, including its currency sign, such as €3.99.
currencyCodestringCurrency code for price and original price.
currencySymbolstringCurrency symbol for price and original price.
isFamilyShareablebooleanBoolean indicating if the product is sharable with family
subscriptionGroupIdentifierstringGroup identifier for the product.
subscriptionPeriodSubscriptionPeriodThe Product subcription group identifier.
introductoryPriceSKProductDiscount | nullThe Product introductory Price.
discountsSKProductDiscount[]The Product discounts list.
SubscriptionPeriod
PropTypeDescription
numberOfUnitsnumberThe Subscription Period number of unit.
unitnumberThe Subscription Period unit.
SKProductDiscount
PropTypeDescription
identifierstringThe Product discount identifier.
typenumberThe Product discount type.
pricenumberThe Product discount price.
priceStringstringFormatted price of the item, including its currency sign, such as €3.99.
currencySymbolstringThe Product discount currency symbol.
currencyCodestringThe Product discount currency code.
paymentModenumberThe Product discount paymentMode.
numberOfPeriodsnumberThe Product discount number Of Periods.
subscriptionPeriodSubscriptionPeriodThe Product discount subscription period.
PurchaserInfo
PropTypeDescription
entitlementsEntitlementInfosEntitlements attached to this purchaser info
activeSubscriptions[string]Set of active subscription skus
allPurchasedProductIdentifiers[string]Set of purchased skus, active and inactive
nonSubscriptionTransactionsTransaction[]Returns all the non-subscription a user has made. The are ordered by purchase date in ascending order.
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
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.
EntitlementInfos

Contains all the entitlements associated to the user.

PropTypeDescription
all{ [key: string]: EntitlementInfo; }Map of all EntitlementInfo (PurchasesEntitlementInfo) objects (active and inactive) keyed by entitlement identifier.
active{ [key: string]: EntitlementInfo; }Map of active EntitlementInfo (PurchasesEntitlementInfo) objects keyed by entitlement identifier.
EntitlementInfo

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). Will always be True if entitlement is for lifetime access.
periodTypestringThe last period type this entitlement was in. Either: NORMAL, INTRO, TRIAL.
latestPurchaseDatestringThe latest purchase or renewal date for the entitlement.
originalPurchaseDatestringThe first date this entitlement was purchased.
expirationDatestring | nullThe expiration date for the entitlement, can be null for lifetime access. If the periodType is trial, this is the trial expiration date.
storestringThe store where this entitlement was unlocked from. Either: appStore, macAppStore, playStore, stripe, promotional, unknownStore
productIdentifierstringThe product identifier that unlocked this entitlement
isSandboxbooleanFalse if this entitlement is unlocked via a production purchase
unsubscribeDetectedAtstring | nullThe date an unsubscribe was detected. Can be null.
billingIssueDetectedAtstring | nullThe date a billing issue was detected. Can be null if there is no billing issue or an issue has been resolved
Transaction
PropTypeDescription
revenueCatIdstringRevenueCat Id associated to the transaction.
productIdstringProduct Id associated with the transaction.
purchaseDatestringPurchase date of the transaction in ISO 8601 format.
Offerings

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

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

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.
availablePackagesPackage[]Array of Package objects available for purchase.
lifetimePackage | nullLifetime package type configured in the RevenueCat dashboard, if available.
annualPackage | nullAnnual package type configured in the RevenueCat dashboard, if available.
sixMonthPackage | nullSix month package type configured in the RevenueCat dashboard, if available.
threeMonthPackage | nullThree month package type configured in the RevenueCat dashboard, if available.
twoMonthPackage | nullTwo month package type configured in the RevenueCat dashboard, if available.
monthlyPackage | nullMonthly package type configured in the RevenueCat dashboard, if available.
weeklyPackage | nullWeekly package type configured in the RevenueCat dashboard, if available.
LogInResult

Holds the logIn result

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

Enums

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.

TODO

Prepare android migration to v5

Keywords

FAQs

Last updated on 21 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc