Search code examples
androidin-app-billingplay-billing-library

In app billing v3 - why I get DEVELOPER_ERROR when calling queryPurchases(skuID)?


I implemented inapp billing (subscriptions) and everything works properly - I am able to subscribe, I acknowledge subscription, and billing flow ends succesfully with OK status.

However, at start of my app I am performing check (from Google Play cache) whether I already made purchases - and I always get DEVELOPER_ERROR.

This is my code:

public void checkIfPurchased() {
        billingClient.startConnection(new BillingClientStateListener() {
            @Override
            public void onBillingSetupFinished(BillingResult billingResult) {
                if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                        Purchase.PurchasesResult alreadyPurchasedResult = billingClient.queryPurchases(SKU_ID);
                        List<Purchase> alreadyPurchased = alreadyPurchasedResult.getPurchasesList();
                        ...
                        // alreadyPurchasedResult = 5 = DEVELOPER_ERROR
                }
            }
    }

Why this happens?


Solution

  • The method queryPurchases accepts as parameter either BillingClient.SkuType.INAPP or BillingClient.SkuType.SUBS as stated in the documentation.

    In your example it looks like you put the SKU ID of your subscription product.