public abstract class BillingClient extends Object
    ↳ com.gaa.sdk.iap.PurchaseClient

It is a default interface for communication between library and user application codes.

All methods are processed as asynchronous ones and should be called up in the UI thread, and all callbacks are returned to the UI thread.

To set up connection after instantiating this class, call up the startConnection(PurchaseClientStateListener method, and once the setup completes, you could receive notifications through listener.

In general, after the setup completes, call up the purchase history check and in-app product details. Refer to queryPurchasesAsync(String, PurchasesListener) and queryProductDetailsAsync(ProductDetailsParams, ProductDetailsListener).

Never forget to call endConnection() when you exit the application after completing all tasks with this object. All the connections with billing modules must be disconnected and resources must be removed. The recommended location is Activity.onDestroy().

To check the detailed logs of library, input android.util.Log.VERBOSE in android.util.Log.VERBOSE and then call them up.

Logger.setLogLevel(int) MUST be removed before launching a release version of an application.


Public methods


public static  newBuilder(Context context)

It generates a builder for creating the PurchaseClient instances.


public abstract void startConnection( listener)

It initiates the PurchaseClient setup process asynchronously.

It receives responses through PurchaseClientStateListener once completed.


public abstract void endConnection()

It cuts the connection with billing modules and removes the resources retained by PurchaseClient.


public abstract void launchUpdateOrInstallFlow(Activity activity,  listener)

When PurchaseClient.ResponseCode.RESULT_NEED_UPDATE occurs, the value of IapResult.getResponseCode() should be called for the update or installation of billing modules.


public abstract  launchPurchaseFlow(Activity activity,  params)

It starts purchasing in-app products.

The purchase screen will be displayed, and the result will be received through PurchasesUpdatedListener, which has been specified when initializing PurchaseClient.


public abstract void consumeAsync( params,  listener)

It consumes purchased in-app products.

Consumption is available only for the in-app product you own, and if the in-app has already been consumed, it is required to be purchased again.

When it comes to API v6 and later, if ‘consume’ or ‘acknowledge’ is not made with 3 days after purchase, refund will be made.


public abstract void acknowledgeAsync( acknowledgeParams,  listener)

It checks purchased in-app products.

Consumption is available only for the in-app product you own, and if the in-app you checked is not consumed, it cannot be purchased again.

It can be applied to both Managed product and Monthly auto-renewal product. In particular, Managed product can be used as ‘Non-renewable’ in which the purchase is acknowledged and then the in-app is consumed after a certain time.

When it comes to API v6 and later, if ‘consume’ or ‘acknowledge’ is not made with 3 days after purchase, refund will be made.


public abstract void queryPurchasesAsync(String productType,  listener)

It imports the purchase information of all in-app products purchased on apps.


public abstract void queryProductDetailsAsync( params,  listener)

It imports the details of in-app products registered on Developer Center.


public abstract void manageRecurringProductAsync( recurringProductParams,  listener)

It changes Monthly auto-renewal product status.

It performs the action either to cancel automatic payment every month or to resume the cancelled automatic payment.


public abstract void launchLoginFlowAsync(Activity activity,  listener)

When PurchaseClient.ResponseCode.RESULT_NEED_LOGIN occurs, the value of IapResult.getResponseCode() performs ONE store login.


public abstract void getStoreInfoAsync( listener)

It imports market identification codes.

This is the value required for using a server to server API.

Last updated