Search in sources :

Example 6 with ConsumeParams

use of com.android.billingclient.api.ConsumeParams in project AmazeFileManager by TeamAmaze.

the class Billing method onPurchasesUpdated.

@Override
public void onPurchasesUpdated(BillingResult response, @Nullable List<Purchase> purchases) {
    if (response.getResponseCode() == BillingClient.BillingResponseCode.OK && purchases != null) {
        for (Purchase purchase : purchases) {
            ConsumeResponseListener listener = (responseCode1, purchaseToken) -> {
                // we consume the purchase, so that user can perform purchase again
                Toast.makeText(activity, R.string.donation_thanks, Toast.LENGTH_LONG).show();
            };
            ConsumeParams consumeParams = ConsumeParams.newBuilder().setPurchaseToken(purchase.getPurchaseToken()).build();
            billingClient.consumeAsync(consumeParams, listener);
        }
    }
}
Also used : BillingClientStateListener(com.android.billingclient.api.BillingClientStateListener) NonNull(androidx.annotation.NonNull) ArrayList(java.util.ArrayList) BuildConfig(com.amaze.filemanager.BuildConfig) BillingResult(com.android.billingclient.api.BillingResult) PurchasesUpdatedListener(com.android.billingclient.api.PurchasesUpdatedListener) Toast(android.widget.Toast) ConsumeParams(com.android.billingclient.api.ConsumeParams) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) DonationViewHolder(com.amaze.filemanager.adapters.holders.DonationViewHolder) Log(android.util.Log) LayoutInflater(android.view.LayoutInflater) SkuDetails(com.android.billingclient.api.SkuDetails) ConsumeResponseListener(com.android.billingclient.api.ConsumeResponseListener) SkuDetailsParams(com.android.billingclient.api.SkuDetailsParams) ViewGroup(android.view.ViewGroup) List(java.util.List) Purchase(com.android.billingclient.api.Purchase) Nullable(androidx.annotation.Nullable) BillingClient(com.android.billingclient.api.BillingClient) AdapterDonationBinding(com.amaze.filemanager.databinding.AdapterDonationBinding) R(com.amaze.filemanager.R) BillingFlowParams(com.android.billingclient.api.BillingFlowParams) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) BasicActivity(com.amaze.filemanager.ui.activities.superclasses.BasicActivity) AppConfig(com.amaze.filemanager.application.AppConfig) Purchase(com.android.billingclient.api.Purchase) ConsumeResponseListener(com.android.billingclient.api.ConsumeResponseListener) ConsumeParams(com.android.billingclient.api.ConsumeParams)

Aggregations

ConsumeParams (com.android.billingclient.api.ConsumeParams)6 BillingResult (com.android.billingclient.api.BillingResult)5 ConsumeResponseListener (com.android.billingclient.api.ConsumeResponseListener)5 NonNull (androidx.annotation.NonNull)3 Purchase (com.android.billingclient.api.Purchase)3 Nullable (androidx.annotation.Nullable)2 AcknowledgePurchaseResponseListener (com.android.billingclient.api.AcknowledgePurchaseResponseListener)2 BillingClient (com.android.billingclient.api.BillingClient)2 BillingClientStateListener (com.android.billingclient.api.BillingClientStateListener)2 BillingFlowParams (com.android.billingclient.api.BillingFlowParams)2 PurchasesUpdatedListener (com.android.billingclient.api.PurchasesUpdatedListener)2 SkuDetails (com.android.billingclient.api.SkuDetails)2 SkuDetailsParams (com.android.billingclient.api.SkuDetailsParams)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1