Package com.revenuecat.purchases

Types

Link copied to clipboard
object AttributionFetcherFactory
Link copied to clipboard
object BillingFactory
Link copied to clipboard
enum CacheFetchPolicy : Enum<CacheFetchPolicy>

Specifies behavior for a caching API.

Link copied to clipboard
typealias ErrorPurchaseCallback = (StoreTransaction, PurchasesError) -> Unit
Link copied to clipboard
class Purchases : LifecycleDelegate

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.

Link copied to clipboard
open class PurchasesConfiguration(builder: PurchasesConfiguration.Builder)
Link copied to clipboard
typealias SuccessfulPurchaseCallback = (StoreTransaction, CustomerInfo) -> Unit
Link copied to clipboard
data class UpgradeInfo(val oldSku: String, val prorationMode: Int? = null)

This object holds the information used when upgrading from another sku.

Functions

Link copied to clipboard
fun Purchases.getCustomerInfoWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

Get latest available customer info.

fun Purchases.getCustomerInfoWith(    fetchPolicy: CacheFetchPolicy,     onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB,     onSuccess: (customerInfo: CustomerInfo) -> Unit)

Get customer info from cache or network depending on fetch policy.

Link copied to clipboard
fun Purchases.getNonSubscriptionSkusWith(    skus: List<String>,     onError: (error: PurchasesError) -> Unit,     onReceiveSkus: (storeProducts: List<StoreProduct>) -> Unit)

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

Link copied to clipboard
fun Purchases.getOfferingsWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (offerings: Offerings) -> Unit)

Fetch the configured offerings for this users. Offerings allows you to configure your in-app products vis RevenueCat and greatly simplifies management. See the guide for more info.

Link copied to clipboard
fun Purchases.getSubscriptionSkusWith(    skus: List<String>,     onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB,     onReceiveSkus: (storeProducts: List<StoreProduct>) -> Unit)

Gets the SKUDetails for the given list of subscription skus.

Link copied to clipboard
fun Purchases.logInWith(    appUserID: String,     onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB,     onSuccess: (customerInfo: CustomerInfo, created: Boolean) -> 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

Link copied to clipboard
fun Purchases.logOutWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

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

Link copied to clipboard
fun Purchases.purchasePackageWith(    activity: Activity,     packageToPurchase: Package,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit)

Make a purchase.

fun Purchases.purchasePackageWith(    activity: Activity,     packageToPurchase: Package,     upgradeInfo: UpgradeInfo,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit)

Make a purchase upgrading from a previous sku.

Link copied to clipboard
fun Purchases.purchaseProductWith(    activity: Activity,     storeProduct: StoreProduct,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit)

Purchase product.

fun Purchases.purchaseProductWith(    activity: Activity,     storeProduct: StoreProduct,     upgradeInfo: UpgradeInfo,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit)

Make a purchase upgrading from a previous sku.

Link copied to clipboard
fun Purchases.restorePurchasesWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

Restores purchases made with the current Play Store account for the current user. This method will post all purchases associated with the current Play Store account to RevenueCat and become associated with the current appUserID. If the receipt token is being used by an existing user, the current appUserID will be aliased together with the appUserID of the existing user. Going forward, either appUserID will be able to reference the same user.