Automatic Purchase Controller
class AutomaticPurchaseController(var context: Context, val scope: IOScope, val entitlementsInfo: () -> Entitlements = { Superwall.instance.dependencyContainer.entitlements }, val getBilling: (Context, PurchasesUpdatedListener) -> BillingClient = { ctx, listener ->
try {
BillingClient
.newBuilder(ctx)
.setListener(listener)
.enablePendingPurchases(
PendingPurchasesParams.newBuilder().enableOneTimeProducts().build(),
).build()
} catch (e: Throwable) {
Logger.debug(
logLevel = LogLevel.error,
scope = LogScope.nativePurchaseController,
message = BILLING_INSANTIATION_ERROR,
info = mapOf("error_message" to (e.message ?: "Unknown message")),
error = e,
)
throw e
}
}) : PurchaseController, PurchasesUpdatedListener(source)
Constructors
Link copied to clipboard
constructor(context: Context, scope: IOScope, entitlementsInfo: () -> Entitlements = { Superwall.instance.dependencyContainer.entitlements }, getBilling: (Context, PurchasesUpdatedListener) -> BillingClient = { ctx, listener ->
try {
BillingClient
.newBuilder(ctx)
.setListener(listener)
.enablePendingPurchases(
PendingPurchasesParams.newBuilder().enableOneTimeProducts().build(),
).build()
} catch (e: Throwable) {
Logger.debug(
logLevel = LogLevel.error,
scope = LogScope.nativePurchaseController,
message = BILLING_INSANTIATION_ERROR,
info = mapOf("error_message" to (e.message ?: "Unknown message")),
error = e,
)
throw e
}
})
Functions
Link copied to clipboard
open override fun onPurchasesUpdated(billingResult: BillingResult, purchases: MutableList<Purchase>?)
Link copied to clipboard
open suspend fun purchase(activity: Activity, product: StoreProduct, basePlanId: String?, offerId: String?): PurchaseResult
open suspend override fun purchase(activity: Activity, productDetails: ProductDetails, basePlanId: String?, offerId: String?): PurchaseResult
Called when the user initiates purchasing of a product.
Link copied to clipboard
Called when the user initiates a restore.