launchBillingFlowWithSuperwall

fun BillingClient.launchBillingFlowWithSuperwall(activity: Activity, params: SuperwallBillingFlowParams): BillingResult(source)

Extension function for BillingClient that launches the Google Play billing flow while allowing Superwall to observe the purchase.

This method acts as a proxy between your app's purchase flow and Google Play Billing, enabling Superwall to track the purchase lifecycle when observer mode is enabled. It wraps the standard BillingClient.launchBillingFlow method and adds purchase observation capabilities.

The method will:

  1. Check if Superwall SDK is initialized

  2. Verify if purchase observation is enabled via SuperwallOptions.shouldObservePurchases

  3. Notify Superwall before each product purchase begins

  4. Launch the actual billing flow

Purchase events can then be observed through Superwall.delegate or Superwall.placements, which will emit events like:

  • SuperwallEvent.TransactionStart when purchase begins

  • SuperwallEvent.TransactionComplete on successful purchase

  • SuperwallEvent.TransactionFail on purchase failure

Return

BillingResult containing the response from launching the billing flow

Parameters

activity

The activity that will host the billing flow

params

Wrapper around BillingFlowParams containing product details for the purchase

See also

Throws

if Superwall SDK is not initialized