StoreManager

class StoreManager(val purchaseController: InternalPurchaseController, val billing: Billing, receiptManagerFactory: () -> ReceiptManager, track: suspend (InternalSuperwallEvent) -> Unit = { Superwall.instance.track(it) }, getSuperwallProducts: suspend () -> Either<SuperwallProductsResponse, NetworkError> = { Either.Success(SuperwallProductsResponse(emptyList())) }, var testMode: TestMode? = null) : ProductsFetcher, StoreKit(source)

Constructors

Link copied to clipboard
constructor(purchaseController: InternalPurchaseController, billing: Billing, receiptManagerFactory: () -> ReceiptManager, track: suspend (InternalSuperwallEvent) -> Unit = { Superwall.instance.track(it) }, getSuperwallProducts: suspend () -> Either<SuperwallProductsResponse, NetworkError> = { Either.Success(SuperwallProductsResponse(emptyList())) }, testMode: TestMode? = null)

Properties

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

The country code of the user's Play Store account, loaded once per app start via loadStorefrontCountryCode. null until loaded or if billing is unavailable.

Link copied to clipboard

Functions

Link copied to clipboard
open override fun cacheProduct(fullProductIdentifier: String, storeProduct: StoreProduct)
Link copied to clipboard
open suspend override fun consume(purchaseToken: String): Result<String>
Link copied to clipboard
suspend fun fetchAndCacheCustomProducts(candidateIds: Set<String>, required: Boolean)

Fetches custom (store == CUSTOM) products from the Superwall /products endpoint and caches them so downstream lookups resolve them from cache instead of Google Play Billing. Ids that are already cached, empty, or absent from /products are left untouched (the latter fall through to billing).

Link copied to clipboard
open override fun getProductFromCache(productId: String): StoreProduct?
Link copied to clipboard
open suspend override fun getProducts(substituteProducts: Map<String, StoreProduct>?, paywall: Paywall, request: PaywallRequest?): GetProductsResponse
Link copied to clipboard
open suspend override fun getProductsWithoutPaywall(productIds: List<String>, substituteProducts: Map<String, StoreProduct>?): Map<String, StoreProduct>
Link copied to clipboard
open suspend override fun getProductVariables(paywall: Paywall, request: PaywallRequest): List<ProductVariable>
Link copied to clipboard
open override fun hasCached(productId: String): Boolean
Link copied to clipboard
open suspend override fun loadPurchasedProducts(serverEntitlementsByProductId: Map<String, Set<Entitlement>>)
Link copied to clipboard

Loads the storefront country code from the Play billing config. The value can't change without the user switching Play accounts, so it's fetched once per app start.

Link copied to clipboard
open suspend override fun products(identifiers: Set<String>): Set<StoreProduct>
Link copied to clipboard
open override fun refreshReceipt()