abstract class BillingClient
BillingClient
()
|
Signature
constructor() Returns |
acknowledgePurchase
(
params
, listener
)
|
Acknowledges in-app purchases.
Developers are required to acknowledge that they have granted entitlement for all in-app purchases for their application.
Warning! All purchases require acknowledgement. Failure to acknowledge a purchase will result in that purchase being refunded. For one-time products ensure you are using BillingClient.consumeAsync which acts as an implicit acknowledgement or you can explicitly acknowledge the purchase via this method. For subscriptions use BillingClient.acknowledgePurchase. Please refer to the integration guide for more details.
Signature
abstract fun acknowledgePurchase(params: AcknowledgePurchaseParams, listener: AcknowledgePurchaseResponseListener) Parameters
params:
AcknowledgePurchaseParams
listener:
AcknowledgePurchaseResponseListener |
consumeAsync
(
params
, listener
)
|
Consumes a given in-app product. Consuming can only be done on an item that's owned, and as a result of consumption, the user will no longer own it.
Consumption is done asynchronously and the listener receives the callback specified upon completion.
Warning! All purchases require acknowledgement. Failure to acknowledge a purchase will result in that purchase being refunded. For one-time products ensure you are using this method which acts as an implicit acknowledgement or you can explicitly acknowledge the purchase via BillingClient.acknowledgePurchase. For subscriptions use BillingClient.acknowledgePurchase. Please refer to https://developer.android.com/google/play/billing/billing_library_overview#acknowledge for more details.
Signature
abstract fun consumeAsync(params: ConsumeParams, listener: ConsumeResponseListener) Parameters
params:
ConsumeParams
listener:
ConsumeResponseListener |
createAlternativeBillingOnlyReportingDetailsAsync
(
listener
)
|
Google Play Billing Library allows developers to create alternative billing only purchase details that can be used to report a transaction made via alternative billing without user choice to use Google Play billing.
Alternative Billing for IAP is not supported by Meta for IAP, so this method should not be called.
Signature
abstract fun createAlternativeBillingOnlyReportingDetailsAsync(listener: AlternativeBillingOnlyReportingDetailsListener) Parameters
The listener for the response of the create alternative billing only reporting details flow.
|
createExternalOfferReportingDetailsAsync
(
listener
)
|
Creates purchase details that can be used to report a transaction made via external offer.
Signature
abstract fun createExternalOfferReportingDetailsAsync(listener: ExternalOfferReportingDetailsListener) Parameters
listener:
ExternalOfferReportingDetailsListener |
endConnection
()
|
Closes the connection and releases all held resources such as service connections.
Call this method once you are done with this BillingClient reference, and when Activity or Fragment is destroyed to avoid memory leak.
Signature
abstract fun endConnection() |
getBillingConfigAsync
(
params
, listener
)
|
Gets the billing config, which stores configuration used to perform billing operations.
Note: This method is not supported, and will currently call the listener with a BillingResult with BillingClient.BillingResponseCode.Companion.FEATURE_NOT_SUPPORTED error code.
Signature
abstract fun getBillingConfigAsync(params: GetBillingConfigParams, listener: BillingConfigResponseListener) Parameters
params:
GetBillingConfigParams
listener:
BillingConfigResponseListener |
getConnectionState
()
|
Get the current billing client connection state.
Signature
abstract fun getConnectionState(): Int |
isAlternativeBillingOnlyAvailableAsync
(
listener
)
|
In the Google Play Billing Library, this checks the availability of offering alternative billing without user choice to use Google Play billing.
Alternative Billing for IAP is not supported by Meta, so this method should not be called.
The listener's callback will not be called.
Signature
abstract fun isAlternativeBillingOnlyAvailableAsync(listener: AlternativeBillingOnlyAvailabilityListener) Parameters |
isExternalOfferAvailableAsync
(
listener
)
|
Checks the availability of providing external offer.
Note: This data can change and should not be cached.
Signature
abstract fun isExternalOfferAvailableAsync(listener: ExternalOfferAvailabilityListener) Parameters
listener:
ExternalOfferAvailabilityListener |
isFeatureSupported
(
feature
)
|
Checks if the specified feature or capability is supported.
Signature
abstract fun isFeatureSupported(feature: String): BillingResult Parameters Returns |
isReady
()
|
Checks if the client is currently connected to the service, so that requests to other methods will succeed.
Returns true if the client is currently connected to the service, false otherwise.
Note: It also means that INAPP items are supported for purchasing, queries and all other actions. If you need to check support for SUBSCRIPTIONS or something different, use BillingClient.isFeatureSupported method.
Signature
abstract fun isReady(): Boolean Returns
Boolean
|
launchBillingFlow
(
activity
, params
)
|
Initiates the billing flow for an in-app purchase or subscription.
It will launch Meta's checkout flow. The result will be delivered via the PurchasesUpdatedListener interface implementation set by BillingClient.Builder.setListener.
Signature
abstract fun launchBillingFlow(activity: Activity, params: BillingFlowParams): BillingResult Parameters
activity:
Activity
Returns |
launchPriceChangeConfirmationFlow
(
activity
, params
, listener
)
DeprecatedThis method has been removed from Play Billing Library since version 6.0.0. |
Launch a price change confirmation flow.
This deprecated method is included for backwards compatibility.
Signature
abstract fun launchPriceChangeConfirmationFlow(activity: Activity, params: PriceChangeFlowParams, listener: PriceChangeConfirmationListener) Parameters
activity:
Activity
listener:
PriceChangeConfirmationListener |
queryAgeCategoryAsync
(
listener
)
|
Returns the AgeCategory of the user.
Signature
abstract fun queryAgeCategoryAsync(listener: AgeCategoryResponseListener) Parameters
listener:
AgeCategoryResponseListener |
queryProductDetailsAsync
(
params
, listener
)
|
Performs a network query the details of products available for sale in your app.
Signature
abstract fun queryProductDetailsAsync(params: QueryProductDetailsParams, listener: ProductDetailsResponseListener) Parameters
params:
QueryProductDetailsParams
listener:
ProductDetailsResponseListener |
queryPurchaseHistoryAsync
(
queryPurchaseHistoryParams
, listener
)
DeprecatedUse [queryPurchasesAsync] instead. |
Returns purchases details for items bought within your app. Only the most recent purchase made by the user for each SKU is returned.
If the network call to fetch the purchases fails, this method will try to return purchases of durable add-ons stored in the client-side cache. The BillingResult will have a BillingClient.BillingResponseCode.Companion.SERVICE_UNAVAILABLE error code.
Signature
abstract fun queryPurchaseHistoryAsync(queryPurchaseHistoryParams: QueryPurchaseHistoryParams, listener: PurchaseHistoryResponseListener) Parameters
listener:
PurchaseHistoryResponseListener |
queryPurchaseHistoryAsync
(
skuType
, listener
)
DeprecatedUse [queryPurchasesAsync] instead. |
Returns purchases details for items bought within your app. Only the most recent purchase made by the user for each SKU is returned.
If the network call to fetch the purchases fails, this method will try to return purchases of durable add-ons stored in the client-side cache. The BillingResult will have a BillingClient.BillingResponseCode.Companion.SERVICE_UNAVAILABLE error code.
Signature
abstract fun queryPurchaseHistoryAsync(skuType: String, listener: PurchaseHistoryResponseListener) Parameters
listener:
PurchaseHistoryResponseListener |
queryPurchasesAsync
(
skuType
, listener
)
DeprecatedUse [queryPurchasesAsync] instead |
Returns purchases details for currently owned items bought within your app.
Only active subscriptions and non-consumed one-time purchases are returned.
If the network call to fetch the purchases fails, this method will try to return purchases of durable add-ons stored in the client-side cache. The BillingResult will have a BillingClient.BillingResponseCode.Companion.SERVICE_UNAVAILABLE error code.
Signature
abstract fun queryPurchasesAsync(skuType: String, listener: PurchasesResponseListener) Parameters
listener:
PurchasesResponseListener |
queryPurchasesAsync
(
queryPurchasesParams
, listener
)
|
Returns purchases details for currently owned items bought within your app.
Only active subscriptions and non-consumed one-time purchases are returned.
If the network call to fetch the purchases fails, this method will try to return purchases of durable add-ons stored in the client-side cache. The BillingResult will have a BillingClient.BillingResponseCode.Companion.SERVICE_UNAVAILABLE error code.
Signature
abstract fun queryPurchasesAsync(queryPurchasesParams: QueryPurchasesParams, listener: PurchasesResponseListener) Parameters
listener:
PurchasesResponseListener |
querySkuDetailsAsync
(
params
, listener
)
DeprecatedUse queryProductDetailsAsync instead |
Performs a network query to get SKU details and return the result asynchronously.
Signature
abstract fun querySkuDetailsAsync(params: SkuDetailsParams, listener: SkuDetailsResponseListener) Parameters
listener:
SkuDetailsResponseListener |
showAlternativeBillingOnlyInformationDialog
(
activity
, listener
)
|
Shows the alternative billing only information dialog on top of the calling app.
Alternative Billing for IAP is not supported by Meta, so this method should not be called.
If this dialog has previously been shown and acknowledged by the user on the app and device, it won't be shown again.
The listener will be invoked on the UI thread on completion.
Signature
abstract fun showAlternativeBillingOnlyInformationDialog(activity: Activity, listener: AlternativeBillingOnlyInformationDialogListener): BillingResult Parameters
activity:
Activity
Returns |
showExternalOfferInformationDialog
(
activity
, listener
)
|
Shows the external offer information dialog on top of the calling app.
The listener will be invoked on the UI thread on completion.
Signature
abstract fun showExternalOfferInformationDialog(activity: Activity, listener: ExternalOfferInformationDialogListener): BillingResult Parameters
activity:
Activity
listener:
ExternalOfferInformationDialogListener Returns BillingClient.BillingResponseCode.Companion.OK if the request is successfully submitted to Play Store, or an error code otherwise.
|
showInAppMessages
(
activity
, params
, listener
)
|
Overlays billing related messages on top of the calling app.
For example, show a message to inform users that their subscription payment has been declined and provide options to take them to fix their payment method.
Callback will be returned on UI thread.
Signature
abstract fun showInAppMessages(activity: Activity, params: InAppMessageParams, listener: InAppMessageResponseListener): BillingResult Parameters
activity:
Activity
listener:
InAppMessageResponseListener Returns BillingClient.BillingResponseCode.Companion.OK if the request is successfully submitted to Play Store, or an error code otherwise.
|
startConnection
(
listener
)
|
Starts up BillingClient setup process asynchronously. You will be notified through the BillingClientStateListener listener when the setup process is complete.
Signature
abstract fun startConnection(listener: BillingClientStateListener) Parameters
listener:
BillingClientStateListener |
connectionState
: Int
[Get][Set] |
Signature
var connectionState: Int |
newBuilder
(
context
)
|
Signature
fun newBuilder(context: Context): BillingClient.Builder Parameters
context:
Context
Returns
BillingClient.Builder
|
class Builder
build
()
| |
enableAlternativeBillingOnly
()
|
In the Google Play Billing Library, this enables the ability to offer alternative billing without user choice to use Google Play billing.
Alternative Billing for IAP is not supported by Meta, so this method should not be called.
Signature
fun enableAlternativeBillingOnly(): BillingClient.Builder Returns
BillingClient.Builder
|
enableExternalOffer
()
|
Enables the ability to offer external offer.
Signature
fun enableExternalOffer(): BillingClient.Builder Returns
BillingClient.Builder
|
enablePendingPurchases
(
pendingPurchasesParams
)
|
Enables pending purchase support.
Signature
fun enablePendingPurchases(pendingPurchasesParams: PendingPurchasesParams): BillingClient.Builder Parameters
pendingPurchasesParams:
PendingPurchasesParams Returns
BillingClient.Builder
|
enablePendingPurchases
()
DeprecatedUse [enablePendingPurchases] instead |
Signature
fun enablePendingPurchases(): BillingClient.Builder Returns
BillingClient.Builder
|
enableUserChoiceBilling
(
userChoiceBillingListener
)
|
The Google Play Billing Library allows developers to select an alternative billing option during the purchase flow and registers a listener.
Alternative Billing for IAP is not supported by Meta, so this method should not be called.
Signature
fun enableUserChoiceBilling(userChoiceBillingListener: UserChoiceBillingListener): BillingClient.Builder Parameters
userChoiceBillingListener:
UserChoiceBillingListener Returns
BillingClient.Builder
|
setAppId
(
appId
)
|
Specifies the Id of the application configured in the Meta Horizon Developer Dashboard.
Optional.
Signature
fun setAppId(appId: String): BillingClient.Builder Parameters
appId:
String
Returns
BillingClient.Builder
|
setListener
(
listener
)
|
Specifies a valid listener for PurchasesUpdatedListener.onPurchasesUpdated events.
Signature
fun setListener(listener: PurchasesUpdatedListener): BillingClient.Builder Parameters
listener:
PurchasesUpdatedListener Returns
BillingClient.Builder
|
annotation class ProductType
ProductType
()
|
Signature
constructor() Returns
BillingClient.ProductType
|
INAPP
: String
[Get] |
A Product type for Android apps in-app products.
Signature
const val INAPP: String |
SUBS
: String
[Get] |
A Product type for Android apps subscriptions.
Signature
const val SUBS: String |
annotation class SkuType
SkuType
()
|
Signature
constructor() Returns
BillingClient.SkuType
|
INAPP
: String
[Get] |
A type of SKU for Android apps in-app products.
Signature
const val INAPP: String |
SUBS
: String
[Get] |
A type of SKU for Android apps subscriptions.
Signature
const val SUBS: String |
annotation class BillingResponseCode
BillingResponseCode
()
|
Signature
constructor() Returns
BillingClient.BillingResponseCode
|
BILLING_UNAVAILABLE
: Int
[Get] |
A user billing error occurred during processing.
Letting the user retry may succeed if the condition causing the error has changed (e.g. An enterprise user's admin has allowed purchases for the organization).
Signature
const val BILLING_UNAVAILABLE: Int = 3 |
DEVELOPER_ERROR
: Int
[Get] |
Error resulting from incorrect usage of the API.
Examples where this error may occur:
Invalid arguments such as providing an empty product list where required. Misconfiguration of the app such as not signing the app or not having the necessary permissions in the manifest.
Signature
const val DEVELOPER_ERROR: Int = 5 |
ERROR
: Int
[Get] |
Fatal error during the API action.
This is an internal error that may be transient or due to an unexpected condition during processing or platform initialization. You can automatically retry (e.g. with exponential back off) for this case and contact Meta if issues persist. Be mindful of how long you retry if the retry is happening during a user interaction.
Signature
const val ERROR: Int = 6 |
FEATURE_NOT_SUPPORTED
: Int
[Get] |
The requested feature is not supported by the Store on the current device.
If your app would like to check if a feature is supported before trying to use the feature your app can call BillingClient.isFeatureSupported to check if a feature is supported. For a list of feature types that can be supported, see BillingClient.FeatureType.
For example: Before calling BillingClient.showInAppMessages API, you can call BillingClient.isFeatureSupported with the BillingClient.FeatureType.Companion.IN_APP_MESSAGING featureType to check if it is supported.
Signature
const val FEATURE_NOT_SUPPORTED: Int |
ITEM_ALREADY_OWNED
: Int
[Get] |
The purchase failed because the item is already owned.
Signature
const val ITEM_ALREADY_OWNED: Int = 7 |
ITEM_NOT_OWNED
: Int
[Get] |
Requested action on the item failed since it is not owned by the user.
Signature
const val ITEM_NOT_OWNED: Int = 8 |
ITEM_UNAVAILABLE
: Int
[Get] |
The requested product is not available for purchase.
Please ensure the product is available in the user’s country. If you recently changed the country availability and are still receiving this error then it may be because of a propagation delay.
Signature
const val ITEM_UNAVAILABLE: Int = 4 |
NETWORK_ERROR
: Int
[Get] |
A network error occurred during the operation.
This error indicates that there was a problem with the network connection between the device and Meta's services. This could potentially also be due to the user not having an active network connection.
Signature
const val NETWORK_ERROR: Int = 12 |
OK
: Int
[Get] |
Success.
Signature
const val OK: Int = 0 |
SERVICE_DISCONNECTED
: Int
[Get] |
The app is not connected to the Store because Platform SDK has not been initialized.
Signature
const val SERVICE_DISCONNECTED: Int |
SERVICE_TIMEOUT
: Int
[Get] DeprecatedUse [BillingResponseCode.SERVICE_UNAVAILABLE] instead |
This field is deprecated.
Signature
const val SERVICE_TIMEOUT: Int |
SERVICE_UNAVAILABLE
: Int
[Get] |
The service is currently unavailable.
Since this state is transient, your app should automatically retry (e.g. with exponential back off) to recover from this error. Be mindful of how long you retry if the retry is happening during a user interaction.
Signature
const val SERVICE_UNAVAILABLE: Int = 2 |
USER_CANCELED
: Int
[Get] |
Transaction was canceled by the user.
Signature
const val USER_CANCELED: Int = 1 |
annotation class ConnectionState
ConnectionState
()
|
Signature
constructor() Returns
BillingClient.ConnectionState
|
CLOSED
: Int
[Get] |
This client was already closed and shouldn't be used again.
Signature
const val CLOSED: Int = 3 |
CONNECTED
: Int
[Get] |
This client is currently connected to billing service.
Signature
const val CONNECTED: Int = 2 |
CONNECTING
: Int
[Get] |
This client is currently in process of connecting to billing service.
Signature
const val CONNECTING: Int = 1 |
DISCONNECTED
: Int
[Get] |
This client was not yet connected to billing service or was already closed.
Signature
const val DISCONNECTED: Int = 0 |
annotation class FeatureType
FeatureType
()
|
Signature
constructor() Returns
BillingClient.FeatureType
|
ALTERNATIVE_BILLING_ONLY
: String
[Get] |
Alternative billing only.
Signature
const val ALTERNATIVE_BILLING_ONLY: String |
BILLING_CONFIG
: String
[Get] |
Get billing config.
Signature
const val BILLING_CONFIG: String |
EXTERNAL_OFFER
: String
[Get] |
Play billing library support for external offer.
Signature
const val EXTERNAL_OFFER: String |
IN_APP_MESSAGING
: String
[Get] |
Show in-app messages.
Signature
const val IN_APP_MESSAGING: String |
PRICE_CHANGE_CONFIRMATION
: String
[Get] |
Launch a price change confirmation flow.
Signature
const val PRICE_CHANGE_CONFIRMATION: String |
PRODUCT_DETAILS
: String
[Get] |
Play billing library support for querying and purchasing.
Signature
const val PRODUCT_DETAILS: String |
SUBSCRIPTIONS
: String
[Get] |
Purchase/query for subscriptions.
Signature
const val SUBSCRIPTIONS: String |
SUBSCRIPTIONS_UPDATE
: String
[Get] |
Subscriptions update/replace.
Signature
const val SUBSCRIPTIONS_UPDATE: String |
annotation class AgeCategory
AgeCategory
()
|
Signature
constructor() Returns
BillingClient.AgeCategory
|
ADULT
: Int
[Get] |
Adult age group for users ages 18 and up (or applicable age in user's region).
Signature
const val ADULT: Int = 3 |
CHILD
: Int
[Get] |
Child age group for users between the ages of 10-12 (or applicable age in user's region).
Signature
const val CHILD: Int = 1 |
TEEN
: Int
[Get] |
Teenage age group for users between the ages of 13-17 (or applicable age in user's region).
Signature
const val TEEN: Int = 2 |
UNKNOWN
: Int
[Get] |
Signature
const val UNKNOWN: Int = 0 |