Register now for Android Dev Summit 2019!

BillingClient.Builder

public static final class BillingClient.Builder
extends Object

java.lang.Object
   ↳ com.android.billingclient.api.BillingClient.Builder


Builder to configure and create a BillingClient instance.

Summary

Public methods

BillingClient build()

Creates a Billing client instance.

BillingClient.Builder enablePendingPurchases()

Enables pending purchase support.

BillingClient.Builder setChildDirected(int childDirected)

Developers are able to specify whether this app is child directed or not to ensure compliance with US COPPA & EEA age of consent laws.

BillingClient.Builder setListener(PurchasesUpdatedListener listener)

Specify a valid listener for onPurchasesUpdated event.

BillingClient.Builder setUnderAgeOfConsent(int underAgeOfConsent)

Developers are able to specify whether this app is under age of consent or not to ensure compliance with US COPPA & EEA age of consent laws.

Inherited methods

From class java.lang.Object

Public methods

build

BillingClient build ()

Creates a Billing client instance.

After creation, it will not yet be ready to use. You must initiate setup by calling startConnection(BillingClientStateListener) and wait for setup to complete.

Returns
BillingClient BillingClient instance

Throws
IllegalArgumentException if Context or PurchasesUpdatedListener were not set.

enablePendingPurchases

BillingClient.Builder enablePendingPurchases ()

Enables pending purchase support.

This method is required to be called to acknowledge your application has been updated to support purchases that are pending. Pending purchases are not automatically enabled since your application will require updates to ensure entitlement is not granted before payment has been secured. For more information on how to handle pending transactions see https://developer.android.com/google/play/billing/billing_library_overview.

If this method is not called, BillingClient instance creation fails.

Returns
BillingClient.Builder

setChildDirected

BillingClient.Builder setChildDirected (int childDirected)

Developers are able to specify whether this app is child directed or not to ensure compliance with US COPPA & EEA age of consent laws.

This is most relevant for rewarded skus as child directed applications are explicitly not allowed to collect information that can be used to personalize the rewarded videos to the user.

Parameters
childDirected int

Returns
BillingClient.Builder

setListener

BillingClient.Builder setListener (PurchasesUpdatedListener listener)

Specify a valid listener for onPurchasesUpdated event.

Parameters
listener PurchasesUpdatedListener: Your listener for app initiated and Play Store initiated purchases.

Returns
BillingClient.Builder

setUnderAgeOfConsent

BillingClient.Builder setUnderAgeOfConsent (int underAgeOfConsent)

Developers are able to specify whether this app is under age of consent or not to ensure compliance with US COPPA & EEA age of consent laws.

This is most relevant for rewarded skus as under age of consent applications are explicitly not allowed to collect information that can be used to personalize the rewarded videos to the user.

Parameters
underAgeOfConsent int

Returns
BillingClient.Builder