1

I want every time I start the application check if a premium user has bought. I do not have a server and I want to perform all actions in the client. I write the value whether there is a premium in a global variable Application class. I wrote a function and it works, I've tested many times everything seems to work. But the last time I made a refund through Google Developer Console, the premium version remained in the application. When I deleted the data and cache, Google Play Market premium disappeared.

public void checkIsPremium(){
    if (billingClient != null && billingClient.isReady()){
        billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, (billingResult, list) -> {               
            if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list.size() != 0){
                if (list.get(0).getPurchaseState() == Purchase.PurchaseState.PURCHASED && list.get(0).isAcknowledged()){
                    if (verifyValidSignature(list.get(0).getOriginalJson(), list.get(0).getSignature())){
                       //The user has a premium
                        AppGlobal.getInstance().setIsPremium(true);
                    }
                }
            }
        });
    }

I have 2 questions:

  1. Can I use queryPurchasesAsync() to find out that a user has bought an item?
  2. Users can refund and keep the premium, what should I do?

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.