DefaultBillingRepository

class DefaultBillingRepository : PurchasesUpdatedListener, BillingRepository(source)

Process-scoped Play Billing implementation.

The repository owns one BillingClient, reconnects with bounded retries, replays the latest product query, and emits purchase outcomes as one-off events. One-time donations are consumed and subscriptions are acknowledged. Unsettled purchases of both types are recovered on initial connection and later reconnects.

Use getInstance rather than constructing a second callback/listener graph.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val productDetails: Flow<Map<String, ProductDetails>>

Products resolved by queryProductDetails, keyed by product id.

Link copied to clipboard
open override val purchaseResult: Flow<PurchaseResult>

Outcome of each purchase attempt, including failures reported by the Play Billing library.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun launchInAppDonationFlow(activity: Activity, details: ProductDetails)

Starts the purchase flow for a one-time product such as a donation.

Link copied to clipboard
open override fun launchSubscriptionFlow(activity: Activity, details: ProductDetails, offerToken: String? = null)

Starts the purchase flow for a subscription.

Link copied to clipboard
open override fun onPurchasesUpdated(billingResult: BillingResult, purchases: MutableList<Purchase>?)
Link copied to clipboard
open suspend override fun processPastPurchases()

Play Billing answers through its own callbacks, so the queries need no dispatcher switch.

Link copied to clipboard
open suspend override fun queryProductDetails(productIds: List<String>)

Play Billing answers through its own callbacks, so the query needs no dispatcher switch.