BillingClient

This reference document contains the summary of BillingClient class.

Definition and Inheritance

        public abstract class BillingClient extends Object 
                                      
              java.lang.Object
                      gg.now.billingclient.api.BillingClient      

Responsibilities


  • BillingClient is responsible for providing the convenience method for in-app billing operations.
  • BillingClient is an interface responsible for communication between the library and the user application code.
  • Supports Synchronous and Asynchronous callbacks for blocking and non-blocking methods respectively.

Process


You need to perform a setup in order to start using the object. Follow the steps below to perform the setup:

  • Start by calling startConnection(BillingClientStateListener) method. This will establish a listener to be notified about the completion of setup. Once the setup is complete you can start calling other methods.
  • After the setup is complete, you should request an inventory of ‘Owned Items’.
    • To request an inventory, you should start with queryPurchases and querySkuDetailsAsync
  • As soon as you are done with the object, make sure that you perform a proper cleanup by using endConnection().
  • If in case you created this object inside onCreate(bundle), you should use onDestroy() method to dispose it.

Note:

  • This object has a binding with the in-app billing service and the broadcast events manager, hence proper cleanup by disposing of the object, is a mandatory step to ensure there is no leak.
  • All methods should be called from the UI thread
  • All the asynchronous callbacks will be returned on the UI thread.

Summary


Public Constructor

          
          BillingClient ()      

Public Methods

Description
abstract void consumeAsync(String purchaseToken, ConsumeResponseListener listener) Consumes the in-app product
abstract void endConnection() Used for clean-up. Closes all the connections and releases acquired resources
abstract BillingResult isFeatureSupported(String feature) Used to check for a particular feature or capability
abstract boolean isReady() Used to confirm the client connection to the billing service
abstract BillingResult launchBillingFlow (Activity activity, BillingFlowParams params) Used to initiate the billing flow for in-app purchases
static BillingClient.Builder newbuilder(Context context) Used to construct a new BillingClient.Builder instance
abstract void queryPurchaseHistoryAsync(String skuType, PurchaseHistoryResponseListener listener) Lists the most recent in-app purchases by the user for each SKU
abstract Purchase.PurchaseResult queryPurchases(String skuType) Returns the purchase details of currently owned products by the user
abstract void querySkuDetailsAsync(SkuDetailsParams params, SkuDetailsResponseListener listener) Returns Asynchronous results after performing a network query the SKU details
abstract void startConnection(BillingClientStateListener listener) Used to start the BillingClient setup asynchronously

Nested Classes

Description
class BillingClient.Builder Builder to configure the BillingClient instance
@interface BillingClient.FeatureType. Lists features supported by isFeatureSupported()
@interface BillingClient.SkuType Lists supported SKU Types

Inherited Methods

    Class java.lang.object
      
Usage
Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait(long arg0, int arg1)
final void wait(long arg0)
final void wait()

 

×
Text copied to clipboard
Questions? Please reach out to us at dev-support@now.gg