GoogleBillingWrapper

class GoogleBillingWrapper : PurchasesUpdatedListener, BillingClientStateListener, Billing(source)

Constructors

Link copied to clipboard
constructor(context: Context, ioScope: IOScope, appLifecycleObserver: AppLifecycleObserver, factory: GoogleBillingWrapper.Factory, createBillingClient: (PurchasesUpdatedListener) -> BillingClient = playBillingClient(context))

Builds a wrapper with its own product cache and billing connection. The SDK builds its wrapper through the internal constructor, from DependencyContainer.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
var billingClient: BillingClient?

The billing client, once created. Setting null makes the next connection create a new one.

Link copied to clipboard
Link copied to clipboard
val createBillingClient: (PurchasesUpdatedListener) -> BillingClient
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val purchaseResults: MutableStateFlow<InternalPurchaseResult?>

Functions

Link copied to clipboard
open suspend override fun awaitGetProducts(fullProductIds: Set<String>): Set<StoreProduct>

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

Link copied to clipboard
open suspend override fun consume(purchaseToken: String): Result<String>
Link copied to clipboard
open suspend override fun getLatestTransaction(factory: StoreTransactionFactory): StoreTransaction?

Get the latest transaction from the purchaseResults flow.

Link copied to clipboard
open suspend override fun getStorefrontCountryCode(): String?

Fetches the Play Store's com.android.billingclient.api.BillingConfig to learn the country of the user's Play Store account. Waits for the billing client to connect if it hasn't yet; resolves to null if billing is unavailable or the fetch fails.

Link copied to clipboard
open override fun onBillingServiceDisconnected()
Link copied to clipboard
open override fun onBillingSetupFinished(billingResult: BillingResult)
Link copied to clipboard
open override fun onPurchasesUpdated(result: BillingResult, purchases: MutableList<Purchase>?)
Link copied to clipboard
open suspend override fun queryAllPurchases(): List<Purchase>
Link copied to clipboard
open suspend override fun queryAllPurchasesResult(): Result<List<Purchase>>

Every purchase Play returns, or a failure when Play couldn't be asked (billing not ready, a query timed out or its retries ran out). Unlike queryAllPurchases, a failed read is never mistaken for "no purchases".

Link copied to clipboard
open suspend override fun querySubscriptionPurchases(): Result<List<Purchase>>

Fails when Play can't be asked, so a failure is never mistaken for "no subscriptions".

Link copied to clipboard
suspend fun queryType(type: String): Result<List<Purchase>>
Link copied to clipboard
Link copied to clipboard
fun startConnectionOnMainThread(delayMilliseconds: Long = 0)
Link copied to clipboard
fun withConnectedClient(receivingFunction: BillingClient.() -> Unit): Unit?