[EN]PurchaseClient

public abstract class BillingClient extends Object java.lang.Object

↳ com.gaa.sdk.iap.PurchaseClient

The default interface for communication between the library and the user application code. Every method is processed asynchronously. It must be called from the UI thread and every call back is restored to the UI thread. When it calls the startConnection (PurchaseClientStateListener) method and the setting is complete, it can receive notifications through the listener to set the connection setting after instantiating this class.

class YourPurchaseManager implements PurchaseClientStateListener { private PurchaseClient mPurchaseClient; public YourPurchaseManager() { mPurchaseClient = PurchaseClient.newBuilder(activity) .setBase64PublicKey(/* your public key */) .setListener(this) .build(); } ... }

In general, it calls the purchase history check and the details of in-app products. Please refer to queryPurchasesAsync(String, QueryPurchasesListner) and queryProductDetailsAsync(ProductDetailsParams, ProductDetailsListener). Please do not forget to call endConnection() when the work is done with this object and end the application. It needs to disconnect and remove resources from the billing module. The recommended location is Activity.onDestroy(). To check the detailed log of the library, enter android.util.Log.VEROSE in Logger.setLogLevel(int). Caution: Please remove Logger.setLogLevel(int) before releasing the release version of the application.

Summary


Nested classes

@interface

@interface

@interface

@interface

@interface

class

PurchaseClient.Builder A builder that helps create a PurchaseClient instance easily.

Public methods


newBuilder

@AnyThreadpublic static PurchaseClient.Builder newBuilder(Context context) Generates the builder to create a PurchaseClient instance.

Parameters:

context

Used to connect with the payment module by using applicationContext.

Returns:

isReady

@AnyThreadpublic abstract boolean isReady() Checks if the client is connected to the current service to check whether the request of other functions succeed.

Returns:

boolean

getConnectionState

@AnyThreadpublic abstract int getConnectionState() Restores the connection state of the current PurchaseClient.

Returns:

int

The state value that corresponds to PurchaseClient.ConnectionState.

isFeatureSupported

@UiThread public abstract IapResult isFeatureSupported(String feature) Checks whether or not the specified feature is supported by the service.

Parameters:

String

Returns:

IapResult

If the feature is supported, PurchaseClient.ResponseCode.RESULT_OK. If the feature is not supported, PurchaseClient.ResponseCode.ERROR_FEATURE_NOT_SUPPORTED.

startConnection

@AnyThreadpublic abstract void startConnection(PurchaseClientStateListener listener) Starts PurchaseClient setting process asynchronously. It receives responses through PurchaseClientStateListener.

Parameters:

listener

Receives responses when PurchaseClient setting and billing module connections are completed.

endConnection

@AnyThreadpublic abstract void endConnection() Disconnects from the billing module and removes retained resources of PurchaseClient.

launchUpdateOrInstallFlow

@UiThreadpublic abstract void launchUpdateOrInstallFlow(Activity activity, IapResultListener listener) Needs to call for an update or installation of the billing module when the value of IapResult.getResponseCode() occurs as PurchaseClient.ResponseCode.RESULT_NEED_UPDATE

Parameters:

activity

Activity: Refers to the activity to know the flow of update or installation of the billing module.

listener

launchPurchaseFlow

@UiThread public abstract IapResult launchPurchaseFlow(Activity activity, PurchaseFlowParams params) Starts purchasing in-app products. The purchase page displays and it receives response results by PurchasesUpdatedListener that is specified when PurchaseClient was initialized.

Parameters:

activity

Refers to activity to open the purchase page.

params

A parameter to open the PurchaseFlowParams purchase page.

Returns:

IapResult

consumeAsync

@AnyThreadpublic abstract void consumeAsync(ConsumeParams params, ConsumeListener listener) Consumes the purchased products. It can be processed for only owned products and it needs to be purchased again if the products are consumed already. Caution: It will be refunded if it is not consumed or acknowledged within 3 days of the purchase date from API v6.

Parameters:

params

A parameter to consume ConsumeParams.

listener

Receives the result of ConsumeListener consuming work.

acknowledgeAsync

@AnyThread public abstract void acknowledgeAsync(AcknowledgeParams acknowledgeParams, AcknowledgeListener listener) Acknowledges purchased products. It can be processed for only owned products and it can't be purchased again if the acknowledged product is not consumed. It can be applied on all management-type products or monthly auto-renewal products. In particular, for management-type products, it is able to be used as subscription products that can be acknowledged and consumed after a certain time period. Caution: It will be refunded if it doesn't consume or acknowledge within 3 days of the purchase date from API v6.

Parameters:

acknowledgeParams

The parameter to acknowledge the purchase of AcknowledgeParams.

listener

Receives the result of acknowledging the purchase works of AcknowledgeListener.

queryPurchasesAsync

@AnyThread public abstract void queryPurchasesAsync(String productType, [EN]QueryPurchasesListener listener) Brings the purchase information of every purchased product from the app.

Parameters:

productType

Specifies PurchaseClient.ProductType type of products.

listener

Receives the result of QueryPurchasesListener purchase history.

queryProductDetailsAsync

@AnyThread public abstract void queryProductDetailsAsync(ProductDetailsParams params, ProductDetailsListener listener) Brings the detailed information of the registered in-app products in the developer center.

Parameters:

params

It is the parameter to bring ProductDetailsParams product detailed information.

listener

It receives the result of ProductDetailsListener product detailed information.

manageRecurringProductAsync

@AnyThread public abstract void manageRecurringProductAsync(RecurringProductParams recurringProductParams, RecurringProductListener listener) Changes the status of monthly auto-renewal products. It processes the action of canceling automatic payment for every month or resuming the canceled monthly auto-renewal product again.

Parameters:

recurringProductParams

A parameter to change the status of RecurringProductParams monthly auto-renewal status.

listener

Receives the result of RecurringProductListener monthly auto-renewal status change.

launchLoginFlowAsync

@UiThread public abstract void launchLoginFlowAsync(Activity activity, IapResultListener listener) Processes store login when the value PurchaseClient.ResponseCode.RESULT_NEED_LOGIN is occured.

Parameters:

activity

Activity: Refers to the activity to know the flow of store login.

listener

Receives the result of lapResultListener login success or failure.

launchManageSubscription

@UiThread public abstract void launchManageSubscription(Activity activity, SubscriptionParams[EN]SubscriptionParamssubscriptionParams) Moves to the subscription products management menu.

Parameters:

activity

Refers to activity to move to the subscription products management menu.

subscriptionParams

If SubscriptionParams null, it moves to the detail page if there is PurchaseData on the management menu page.

getStoreInfoAsync

@AnyThread public abstract void getStoreInfoAsync(StoreInfoListener listener) Brings the market identification code. This value is required when using server to server API.

Parameters:

listener

Receives the StoreInfoListener market identification code.

Last updated