public abstract class BillingClient
extends java.lang.Object
It provides convenience methods for in-app billing. You can create one instance of this class for your application and use it to process in-app billing operations. It provides asynchronous (non-blocking) methods for many common in-app billing operations.
It's strongly recommended that you instantiate only one BillingClient
instance at one
time since each new instantiation will update the PurchasesUpdatedListener
to the new one
provided, even for other BillingClient
instances.
Modifier and Type | Class and Description |
---|---|
static interface |
BillingClient.BillingResponseCode
Possible response codes.
|
static class |
BillingClient.Builder
Builder to configure and create a
BillingClient instance. |
static interface |
BillingClient.ConnectionState
Connection state of billing client.
|
static interface |
BillingClient.FeatureType
Features/capabilities supported by
isFeatureSupported(String) . |
static interface |
BillingClient.ProductType
Supported Product types.
|
static interface |
BillingClient.SkuType
Supported SKU types.
|
Constructor and Description |
---|
BillingClient() |
Modifier and Type | Method and Description |
---|---|
abstract void |
acknowledgePurchase(AcknowledgePurchaseParams params,
AcknowledgePurchaseResponseListener listener)
Acknowledges in-app purchases.
|
abstract void |
consumeAsync(ConsumeParams consumeParams,
ConsumeResponseListener listener)
Consumes a given in-app product.
|
abstract void |
endConnection()
This is a no-op method since there is no concept of maintaining a connection in the Amazon
Appstore.
|
abstract int |
getConnectionState()
Gets the current billing client connection state.
|
abstract BillingResult |
isFeatureSupported(java.lang.String feature)
Checks if the specified feature or capability is supported by the Amazon Appstore.
|
abstract boolean |
isReady()
Checks if the client is currently connected to the service, so that requests to other methods
will succeed.
|
abstract BillingResult |
launchBillingFlow(android.app.Activity activity,
BillingFlowParams params)
Initiates the billing flow for an in-app purchase.
|
static BillingClient.Builder |
newBuilder(android.content.Context context)
Constructs a new
BillingClient.Builder instance. |
abstract void |
queryProductDetailsAsync(QueryProductDetailsParams params,
ProductDetailsResponseListener listener)
Performs a network query the details of products available for sale in your app.
|
abstract void |
queryPurchasesAsync(QueryPurchasesParams queryPurchasesParams,
PurchasesResponseListener listener)
Returns purchases details for currently owned items bought within your app.
|
abstract void |
queryPurchasesAsync(java.lang.String skuType,
PurchasesResponseListener listener)
Returns purchases details for currently owned items bought within your app.
|
abstract void |
querySkuDetailsAsync(SkuDetailsParams params,
SkuDetailsResponseListener listener)
Performs a network query to get SKU details and return the result asynchronously.
|
abstract void |
startConnection(BillingClientStateListener listener)
Starts up
BillingClient setup process asynchronously. |
public abstract void querySkuDetailsAsync(SkuDetailsParams params, SkuDetailsResponseListener listener)
params
- Params specific to this query request.listener
- The listener for the result of the query operation returned asynchronously
through the callback with the BillingClient.BillingResponseCode
and the list of
SkuDetails
.public abstract void queryProductDetailsAsync(QueryProductDetailsParams params, ProductDetailsResponseListener listener)
params
- Params containing list of QueryProductDetailsParams.Product
where
each product contains product id and BillingClient.ProductType
.listener
- The listener for the result of the query operation returned asynchronously
through the callback with the BillingClient.BillingResponseCode
and
the list of ProductDetails
.public abstract BillingResult launchBillingFlow(android.app.Activity activity, BillingFlowParams params)
The result will be delivered via the PurchasesUpdatedListener
interface
implementation set by BillingClient.Builder.setListener(PurchasesUpdatedListener)
.
activity
- An activity reference from which the billing flow will be launched.params
- Params specific to the launch billing flow request.public abstract void queryPurchasesAsync(java.lang.String skuType, PurchasesResponseListener listener)
skuType
- The type of SKU as in BillingClient.SkuType
.listener
- The listener for the result of the query returned asynchronously through the
callback with the BillingResult
and the list of Purchase
.public abstract void queryPurchasesAsync(QueryPurchasesParams queryPurchasesParams, PurchasesResponseListener listener)
queryPurchasesParams
- Params specific to this query request.listener
- The listener for the result of the query returned asynchronously through the
callback with the BillingResult
and the list of Purchase
.public abstract void acknowledgePurchase(AcknowledgePurchaseParams params, AcknowledgePurchaseResponseListener listener)
Developers are required to acknowledge that they have granted entitlement for all in-app purchases for their application.
params
- Params specific to this acknowledge purchase request.listener
- The listener for the result of the acknowledge operation returned asynchronously
through the callback with the BillingClient.BillingResponseCode
.public abstract void consumeAsync(ConsumeParams consumeParams, ConsumeResponseListener listener)
consumeParams
- Params specific to consuming a purchase.listener
- The listener for the result of the consume operation returned asynchronously
through the callback with the purchase token and BillingClient.BillingResponseCode
.public abstract void startConnection(BillingClientStateListener listener)
BillingClient
setup process asynchronously. You will be notified through
the BillingClientStateListener
listener when the setup process is complete.
This always invokes the listener with BillingClient.BillingResponseCode.OK
since
there is no concept of maintaining a connection in the Amazon Appstore. This is present only
for ease of porting from Google Play Billing
(https://developer.android.com/reference/com/android/billingclient/api/BillingClient#startConnection(com.android.billingclient.api.BillingClientStateListener)).
listener
- The listener to notify when the setup process is complete.public abstract int getConnectionState()
This always returns BillingClient.ConnectionState.CONNECTED
since there is no concept
of maintaining a connection in the Amazon Appstore. This is present only for ease of porting
from Google Play Billing
(https://developer.android.com/reference/com/android/billingclient/api/BillingClient#getConnectionState()).
public abstract boolean isReady()
This always returns true since there is no concept of maintaining a connection in the Amazon Appstore. This is present only for ease of porting from Google Play Billing (https://developer.android.com/reference/com/android/billingclient/api/BillingClient#isReady()).
public abstract void endConnection()
public abstract BillingResult isFeatureSupported(java.lang.String feature)
feature
- One of the BillingClient.FeatureType constants.public static BillingClient.Builder newBuilder(android.content.Context context)
BillingClient.Builder
instance.