ReceiptManager

Builds the device's purchases, entitlements and customer info from the Store's receipts. It reads only neutral store types; the SDK builds it with its own store.

Constructors

Link copied to clipboard
constructor(delegate: ProductsFetcher?, billing: Billing, ioScope: IOScope = IOScope(), storage: Storage, customerInfoManager: () -> CustomerInfoManager, entitlementProcessor: EntitlementProcessor = EntitlementProcessor(), subscriptionStatusProvider: SubscriptionStatusProvider = PlayBillingSubscriptionStatusProvider(billing), currentTimeMillis: () -> Long = System::currentTimeMillis)

Kept for its public signature. billing is read as a Store; a custom subscriptionStatusProvider is still handed the original Play purchase.

Types

Link copied to clipboard
data class PurchaseSnapshot(val purchases: Set<InAppPurchase>, val entitlementsByProductId: Map<String, List<Entitlement>>, val nonSubscriptions: List<NonSubscriptionTransaction>, val subscriptions: List<SubscriptionTransaction>)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Returns experimental device variables for backwards compatibility. These are used in device variables for paywall templating.

Link copied to clipboard
Link copied to clipboard
suspend fun isEligibleForIntroOffer(storeProduct: StoreProduct): Boolean
Link copied to clipboard
Link copied to clipboard
suspend fun loadPurchasedProducts(serverEntitlementsByProductId: Map<String, Set<Entitlement>>)

Loads purchased products from device receipts and builds enriched entitlements.

Link copied to clipboard
suspend fun loadPurchases(serverEntitlementsByProductId: Map<String, Set<Entitlement>>): ReceiptManager.PurchaseSnapshot
Link copied to clipboard
Link copied to clipboard
suspend fun reloadForNewUser(serverEntitlementsByProductId: Map<String, Set<Entitlement>>)

Rebuilds the receipt-derived state after the user scope was wiped (reset or a switch to another user). Play purchases belong to the device's Play account, not the app user, so they're read again and stored for the new user instead of staying empty until the next purchase or restore. The old user's in-memory values are dropped first, so a failed read leaves the new user with no receipt state until the next successful load.