0

I deactivated an in-app product on play console but it still shows up when I do billingClient.queryProductDetails. Seems like the only way is to delete the in-app product but then you can't use the product id anymore.

How do we not show deactivated/inactive products?

Plasty Grove
  • 2,807
  • 5
  • 31
  • 42

2 Answers2

1

When you deactivate an in-app product on Play Console, it can take some time for the changes to propagate across all Google servers. It is possible that the product details are still cached on your device or the Google servers that your app is communicating with.

To ensure that your app does not display inactive products, you can use the SkuDetailsResponseListener interface of the BillingClient object to receive the product details response. In the response, you can check the SkuDetails object's isRewarded and isSubscription fields to determine if the product is active or not.

For example, you can modify your BillingClient.queryProductDetails callback method as follows:

List<String> skuList = new ArrayList<>();
skuList.add("your_product_id");

billingClient.querySkuDetailsAsync(
    SkuDetailsParams.newBuilder()
        .setSkusList(skuList)
        .setType(BillingClient.SkuType.INAPP)
        .build(),
    new SkuDetailsResponseListener() {
        @Override
        public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
            if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && skuDetailsList != null) {
                for (SkuDetails skuDetails : skuDetailsList) {
                    if (!skuDetails.isRewarded() && !skuDetails.isSubscription()) {
                        // This product is inactive, do not display it to the user
                        continue;
                    }
                    // Process the active product
                }
            }
        }
    });

This code snippet checks if the retrieved SkuDetails object is a subscription or a rewarded product, and if it is not, it is skipped and not displayed to the user.

By implementing this check, your app should not display inactive products even if they are still cached on your device or the Google servers.

Martin Čuka
  • 16,134
  • 4
  • 23
  • 49
0

Per: Google Play In-App Purchases - querySkuDetailsAsync doesn't return status (active/inactive)

The only way to currently handle this issue is to handle Active/Inactive within your app, and then filter out those products that are Inactive status.

Effectively, you'll need to push a small change to your app updating a filter table of "Active" and "Inactive" products.

G. Putnam
  • 1,262
  • 5
  • 10