5

When testing subscriptions, it turned out that canceled subscriptions remain active even after their expiration date. At the same time in Google Play subscription list is empty. I tried two popular IAB libs (in-app-billing v3 and android-checkout).

What causes the problem? Is the problem relevant only when testing? Is there a way to check if the subscription is truly active without the need of running own backend?

bp = new BillingProcessor(a,
            "xxx",
            new BillingProcessor.IBillingHandler() {
            ...
                @Override
                public void onBillingInitialized() {
                    bp.loadOwnedPurchasesFromGoogle();
                    bp.isSubscribed(planId); // true for expired cancelled subscription that is not listed in google play
                }
            });

UPD

I implemented in-app billing without external libs by official guidelines (https://developer.android.com/google/play/billing/billing_integrate.html) and now it works as intended although i have to wait some time to cancelled expired subscription become inactive (sometimes an hour, sometimes a day).

HoneyBooBoo
  • 55
  • 1
  • 7

1 Answers1

1

you may try this one.

purchase.getPurchaseState()
// 0 (purchased), 1 (canceled)- 2 (refunded).
eren
  • 46
  • 6
  • 1
    While this code may answer the question, providing additional context regarding **how** and/or **why** it solves the problem would improve the answer's long-term value. – Alexander Apr 01 '18 at 06:51
  • 3
    Unfortunately, in my case this returns 0 instead of 1. – HoneyBooBoo Apr 04 '18 at 18:43
  • I guess this is outdated.. Check the documentation.. https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState – grrigore Dec 03 '21 at 14:10