0

I have a non-consumable one time item. I want to check if item is already purchased or not before launching the purchase flow. I tried lots of things but nothing worked. I searched about it but I couldn't find a solution for v4. Can you help me please?

       billingClient.queryPurchasesAsync(
                         BillingClient.SkuType.INAPP,
                         new PurchasesResponseListener() {
                             @Override
                             public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) {
                                 if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                                     for (Purchase purchase : list) {

                                         if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
                                             //handlePurchase(purchase);
                                             savePurchaseValueToPref(true);
                                         }
                                     }
                                 }
                             }
                         }
                 );

I put this code in onBillingSetupFinished but it didn't work as I wanted

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.