Payments and billing

5 concepts · 15 practice questions

The purchase flow

Connect a BillingClient, query product details to show localized prices, launch the billing flow, and handle results in onPurchasesUpdated. Also query existing purchases when the app starts, because purchases can happen while the app is closed or on another device.

val params = QueryProductDetailsParams.newBuilder()
    .setProductList(listOf(
        QueryProductDetailsParams.Product.newBuilder()
            .setProductId("premium_monthly")
            .setProductType(BillingClient.ProductType.SUBS)
            .build()
    ))
    .build()
billingClient.queryProductDetailsAsync(params) { billingResult, result ->
    if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
        showPrices(result.productDetailsList)
    }
}

Also covered

Acknowledging and consuming
Server verification
Subscriptions
Policy and payment states

Sign in to read the rest and take the 15-question test.

Sign in to continue