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
data class PurchaseParams(val builder: PurchaseParams.Builder)
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

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.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.getProductsWith(    productIds: List<String>,     onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB,     onGetStoreProducts: (storeProducts: List<StoreProduct>) -> Unit)

Gets the StoreProduct(s) for the given list of product ids for all product types.

fun Purchases.getProductsWith(    productIds: List<String>,     type: ProductType?,     onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB,     onGetStoreProducts: (storeProducts: List<StoreProduct>) -> Unit)

Gets the StoreProduct(s) for the given list of product ids of type type

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.purchaseWith(    purchaseParams: PurchaseParams,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit)
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.