Show / Hide Table of Contents

Class AN_BillingClient

Main interface for communication between the library and user application code.

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 synchronous (blocking) and asynchronous (non-blocking) methods for many common in-app billing operations.

All methods are supposed to be called from the Ui thread and all the asynchronous callbacks will be returned on the Ui thread as well.

Inheritance
System.Object
AN_BillingClient
Namespace: SA.Android.Vending.BillingClient
Assembly: cs.temp.dll.dll
Syntax
public class AN_BillingClient : AN_LinkedObject

Methods

AcknowledgePurchase(AN_AcknowledgePurchaseParams, Action<SA_iResult>)

Acknowledge 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 ConsumeAsync(AN_ConsumeParams, AN_iConsumeResponseListener) which acts as an implicit acknowledgement or you can explicitly acknowledge the purchase via this method. For subscriptions use AcknowledgePurchase(AN_AcknowledgePurchaseParams, AN_iAcknowledgePurchaseResponseListener). Please refer to https://developer.android.com/google/play/billing/billing_library_overview#acknowledge for more details.

Declaration
public void AcknowledgePurchase(AN_AcknowledgePurchaseParams params, Action<SA_iResult> callback)
Parameters
Type Name Description
AN_AcknowledgePurchaseParams params

Params specific to this acknowledge purchase request.

Action<SA_iResult> callback

Result of the acknowledge operation returned asynchronously through the callback.

AcknowledgePurchase(AN_AcknowledgePurchaseParams, AN_iAcknowledgePurchaseResponseListener)

Acknowledge 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 ConsumeAsync(AN_ConsumeParams, AN_iConsumeResponseListener) which acts as an implicit acknowledgement or you can explicitly acknowledge the purchase via this method. For subscriptions use AcknowledgePurchase(AN_AcknowledgePurchaseParams, AN_iAcknowledgePurchaseResponseListener). Please refer to https://developer.android.com/google/play/billing/billing_library_overview#acknowledge for more details.

Declaration
public void AcknowledgePurchase(AN_AcknowledgePurchaseParams params, AN_iAcknowledgePurchaseResponseListener listener)
Parameters
Type Name Description
AN_AcknowledgePurchaseParams params

Params specific to this acknowledge purchase request.

AN_iAcknowledgePurchaseResponseListener listener

Implement it to get the result of the acknowledge operation returned asynchronously through the callback.

ConsumeAsync(AN_ConsumeParams, AN_iConsumeResponseListener)

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 AcknowledgePurchase(AN_AcknowledgePurchaseParams, AN_iAcknowledgePurchaseResponseListener). For subscriptions use AcknowledgePurchase(AN_AcknowledgePurchaseParams, AN_iAcknowledgePurchaseResponseListener).

Please refer to https://developer.android.com/google/play/billing/billing_library_overview#acknowledge for more details.

Declaration
public void ConsumeAsync(AN_ConsumeParams consumeParams, AN_iConsumeResponseListener listener)
Parameters
Type Name Description
AN_ConsumeParams consumeParams

Params specific to consume purchase.

AN_iConsumeResponseListener listener

Implement it to get the result of your consume operation returned asynchronously through the callback with token and BillingClient.BillingResponseCode parameters.

EndConnection()

Close the connection and release all held resources such as service connections. Call this method once you are done with this BillingClient reference.

Declaration
public void EndConnection()

IsFeatureSupported(AN_BillingClient.FeatureType)

Check if specified feature or capability is supported by the Play Store.

Declaration
public AN_BillingClient.BillingResponseCode IsFeatureSupported(AN_BillingClient.FeatureType feature)
Parameters
Type Name Description
AN_BillingClient.FeatureType feature

One of AN_BillingClient.FeatureType constants.

Returns
Type Description
AN_BillingClient.BillingResponseCode

Ok if feature is supported and corresponding error code otherwise.

IsReady()

Checks if the client is currently connected to the service, so that requests to other methods will succeed.

Note: It also means that In App items are supported for purchasing, queries and all other actions. If you need to check support for SUBSCRIPTIONS or something different, use IsFeatureSupported(AN_BillingClient.FeatureType) method.

Declaration
public bool IsReady()
Returns
Type Description
System.Boolean

Returns true if the client is currently connected to the service, false otherwise.

LaunchBillingFlow(AN_BillingFlowParams)

Initiate the billing flow for an in-app purchase or subscription. The result will be delivered via the AN_iPurchasesUpdatedListener interface.

Declaration
public void LaunchBillingFlow(AN_BillingFlowParams params)
Parameters
Type Name Description
AN_BillingFlowParams params

NewBuilder()

Constructs a new AN_BillingClient.Builder instance.

Declaration
public static AN_BillingClient.Builder NewBuilder()
Returns
Type Description
AN_BillingClient.Builder

Returns a new AN_BillingClient.Builder instance.

QueryPurchaseHistoryAsync(AN_BillingClient.SkuType, AN_iPurchaseHistoryResponseListener)

Returns the most recent purchase made by the user for each SKU, even if that purchase is expired, canceled, or consumed.

Declaration
public void QueryPurchaseHistoryAsync(AN_BillingClient.SkuType skuType, AN_iPurchaseHistoryResponseListener listener)
Parameters
Type Name Description
AN_BillingClient.SkuType skuType

The type of SKU, either "inapp" or "subs" as in AN_BillingClient.SkuType.

AN_iPurchaseHistoryResponseListener listener

Implement it to get the result of your query operation returned asynchronously through the callback.

QueryPurchases(AN_BillingClient.SkuType)

Get purchases details for all the items bought within your app. This method uses a cache of Google Play Store app without initiating a network request.

Note: It's recommended for security purposes to go through purchases verification on your backend (if you have one) by calling one of the following APIs: https://developers.google.com/android-publisher/api-ref/purchases/products/get https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get

Declaration
public AN_Purchase.PurchasesResult QueryPurchases(AN_BillingClient.SkuType skuType)
Parameters
Type Name Description
AN_BillingClient.SkuType skuType

The type of SKU, either "inapp" or "subs" as in AN_BillingClient.SkuType

Returns
Type Description
AN_Purchase.PurchasesResult

The AN_Purchase.PurchasesResult containing the list of purchases and the response code.

QuerySkuDetailsAsync(AN_SkuDetailsParams, AN_iSkuDetailsResponseListener)

Perform a network query to get SKU details and return the result asynchronously.

Declaration
public void QuerySkuDetailsAsync(AN_SkuDetailsParams params, AN_iSkuDetailsResponseListener listener)
Parameters
Type Name Description
AN_SkuDetailsParams params

Params specific to this query request AN_SkuDetailsParams.

AN_iSkuDetailsResponseListener listener

Implement it to get the result of your query operation returned asynchronously through the callback with the AN_BillingClient.BillingResponseCode and the list of SkuDetails.

StartConnection(AN_iBillingClientStateListener)

Starts up BillingClient setup process asynchronously. You will be notified through the AN_iBillingClientStateListener listener when the setup process is complete.

Declaration
public void StartConnection(AN_iBillingClientStateListener listener)
Parameters
Type Name Description
AN_iBillingClientStateListener listener

The listener to notify when the setup process is complete.

In This Article
Back to top Generated by DocFX