BillingClient class
This class can be used directly instead of InAppPurchaseConnection
to call
Play-specific billing APIs.
Wraps a
com.android.billingclient.api.BillingClient
instance.
In general this API conforms to the Java
com.android.billingclient.api.BillingClient
API as much as possible, with
some minor changes to account for language differences. Callbacks have been
converted to futures where appropriate.
Connection to BillingClient may be lost at any time (see
onBillingServiceDisconnected
param of startConnection and
BillingResponse.serviceDisconnected).
Consider using BillingClientManager that handles these disconnections
transparently.
Constructors
- BillingClient(PurchasesUpdatedListener onPurchasesUpdated, UserSelectedAlternativeBillingListener? alternativeBillingListener, {@visibleForTesting InAppPurchaseApi? api})
- Creates a billing client.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hostCallbackHandler → HostBillingClientCallbackHandler
-
Handlers for calls from the host-side code.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
acknowledgePurchase(
String purchaseToken) → Future< BillingResultWrapper> - Acknowledge an in-app purchase.
-
consumeAsync(
String purchaseToken) → Future< BillingResultWrapper> - Consumes a given in-app product.
-
createAlternativeBillingOnlyReportingDetails(
) → Future< AlternativeBillingOnlyReportingDetailsWrapper> - The details used to report transactions made via alternative billing without user choice to use Google Play billing.
-
enablePendingPurchases(
) → void -
Enable the
BillingClientWrapper
to handle pending purchases. -
endConnection(
) → Future< void> -
Calls
`BillingClient#endConnection(BillingClientStateListener)`
(https://developer.android.com/reference/com/android/billingclient/api/BillingClient.html#endconnect to disconnect aBillingClient
instance. -
getBillingConfig(
) → Future< BillingConfigWrapper> -
Fetches billing config info into a
BillingConfigWrapper
object. -
isAlternativeBillingOnlyAvailable(
) → Future< BillingResultWrapper> - Checks if "AlterntitiveBillingOnly" feature is available.
-
isFeatureSupported(
BillingClientFeature feature) → Future< bool> - Checks if the specified feature or capability is supported by the Play Store. Call this to check if a BillingClientFeature is supported by the device.
-
isReady(
) → Future< bool> -
Calls
BillingClient#isReady()
to get the ready status of the BillingClient instance. -
launchBillingFlow(
{required String product, String? offerToken, String? accountId, String? obfuscatedProfileId, String? oldProduct, String? purchaseToken, ProrationMode? prorationMode, ReplacementMode? replacementMode}) → Future< BillingResultWrapper> -
Attempt to launch the Play Billing Flow for a given
productDetails
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
queryProductDetails(
{required List< ProductWrapper> productList}) → Future<ProductDetailsResponseWrapper> -
Returns a list of ProductDetailsResponseWrappers that have
ProductDetailsWrapper.productId and ProductDetailsWrapper.productType
in
productList
. -
queryPurchaseHistory(
ProductType productType) → Future< PurchasesHistoryResult> - Fetches purchase history for the given ProductType.
-
queryPurchases(
ProductType productType) → Future< PurchasesResultWrapper> - Fetches recent purchases for the given ProductType.
-
showAlternativeBillingOnlyInformationDialog(
) → Future< BillingResultWrapper> - Shows the alternative billing only information dialog on top of the calling app.
-
startConnection(
{required OnBillingServiceDisconnected onBillingServiceDisconnected, BillingChoiceMode billingChoiceMode = BillingChoiceMode.playBillingOnly}) → Future< BillingResultWrapper> -
Calls
BillingClient#startConnection(BillingClientStateListener)
to create and connect aBillingClient
instance. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited