purchases / com.revenuecat.purchases

Package com.revenuecat.purchases

Package that contains all the SDK classes.

Types

Entitlement

class Entitlement : Parcelable

An entitlement represents features or content that a user is "entitled" to. Entitlements are unlocked by having an active subscription or making a one-time purchase. Many different products can unlock. Most subscription apps only have one entitlement, unlocking all premium features. However, if you had two tiers of content such as premium and premium_plus, you would have 2 entitlements. A common and simple setup example is one entitlement with identifier pro, one offering monthly, with one product. See this link for more info

Offering

data class Offering : Parcelable

Most well monetized subscription apps provide many different offerings to purchase an entitlement. These are usually associated with different durations i.e. an annual plan and a monthly plan. See this link for more info

PurchaserInfo

class PurchaserInfo : Parcelable

Class containing all information regarding the purchaser

Purchases

class Purchases

Entry point for Purchases. It should be instantiated as soon as your app has a unique user id for your user. This can be when a user logs in if you have accounts or on launch if you can generate a random user identifier. Make sure you follow the quickstart guide to setup your RevenueCat account.

PurchasesError

class PurchasesError

This class represents an error

PurchasesErrorCode

enum class PurchasesErrorCode

Type Aliases

CallbackCacheKey

typealias CallbackCacheKey = List<String>

EntitlementMapCallback

typealias EntitlementMapCallback = Pair<(Map<String, Entitlement>) -> Unit, (PurchasesError) -> Unit>

PostReceiptCallback

typealias PostReceiptCallback = Pair<(PurchaserInfo) -> Unit, (PurchasesError, shouldConsumePurchase: Boolean) -> Unit>

PurchaserInfoCallback

typealias PurchaserInfoCallback = Pair<(PurchaserInfo) -> Unit, (PurchasesError) -> Unit>

Functions

createAliasWith

fun Purchases.createAliasWith(newAppUserID: String, onError: ErrorFunction = onErrorStub, onSuccess: ReceivePurchaserInfoSuccessFunction): Unit

This function will alias two appUserIDs together.

getEntitlementsWith

fun Purchases.getEntitlementsWith(onError: ErrorFunction = onErrorStub, onSuccess: ReceiveEntitlementsSuccessFunction): Unit

Fetch the configured entitlements for this user. Entitlements allows you to configure your in-app products via RevenueCat and greatly simplifies management. See the guide for more info.

getNonSubscriptionSkusWith

fun Purchases.getNonSubscriptionSkusWith(skus: List<String>, onError: ErrorFunction, onReceiveSkus: (skus: List<SkuDetails>) -> Unit): Unit

Gets the SKUDetails for the given list of non-subscription skus.

getPurchaserInfoWith

fun Purchases.getPurchaserInfoWith(onError: ErrorFunction = onErrorStub, onSuccess: ReceivePurchaserInfoSuccessFunction): Unit

Get latest available purchaser info.

getSubscriptionSkusWith

fun Purchases.getSubscriptionSkusWith(skus: List<String>, onError: ErrorFunction = onErrorStub, onReceiveSkus: (skus: List<SkuDetails>) -> Unit): Unit

Gets the SKUDetails for the given list of subscription skus.

identifyWith

fun Purchases.identifyWith(appUserID: String, onError: ErrorFunction = onErrorStub, onSuccess: ReceivePurchaserInfoSuccessFunction): Unit

This function will change the current appUserID. Typically this would be used after a log out to identify a new user without calling configure

makePurchaseWith

fun Purchases.makePurchaseWith(activity: Activity, sku: String, skuType: String, oldSkus: ArrayList<String>, onError: MakePurchaseErrorFunction = onMakePurchaseErrorStub, onSuccess: MakePurchaseCompletedSuccessFunction): Unit
fun Purchases.makePurchaseWith(activity: Activity, skuDetails: SkuDetails, oldSku: String, onError: MakePurchaseErrorFunction = onMakePurchaseErrorStub, onSuccess: MakePurchaseCompletedSuccessFunction): Unit
fun Purchases.makePurchaseWith(activity: Activity, sku: String, skuType: String, onError: MakePurchaseErrorFunction = onMakePurchaseErrorStub, onSuccess: MakePurchaseCompletedSuccessFunction): Unit
fun Purchases.makePurchaseWith(activity: Activity, skuDetails: SkuDetails, onError: MakePurchaseErrorFunction = onMakePurchaseErrorStub, onSuccess: MakePurchaseCompletedSuccessFunction): Unit

Make a purchase.

resetWith

fun Purchases.resetWith(onError: ErrorFunction = onErrorStub, onSuccess: ReceivePurchaserInfoSuccessFunction): Unit

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

restorePurchasesWith

fun Purchases.restorePurchasesWith(onError: ErrorFunction = onErrorStub, onSuccess: ReceivePurchaserInfoSuccessFunction): Unit

Restores purchases made with the current Play Store account for the current user. If you initialized Purchases with an appUserID any receipt tokens currently being used by other users of your app will not be restored. If you used an anonymous id, i.e. you initialized Purchases without an appUserID, any other anonymous users using the same purchases will be merged.