Ravin
Ravin

Reputation: 21

Cancelling In App Test Subscriptions

I'm testing an app which has an in-app subscription feature. I used test subscriptions to test the purchase which seem to work. I then wanted to test that the app responds to cancelled subscriptions so I cancelled the subscription from within Play. However the getPurchase() call still returns the purchase object. I'm using the code from the TrivalDrive sample including the IABHelper.

        if (refsub != null && refsub.isAutoRenewing()) {
            mRefTechSku = REFTECH_SKU;
            mAutoRenewEnabled = true;
        } else {
            mRefTechSku = "";
            mAutoRenewEnabled = false;
        }

        // The user is subscribed if either subscription exists, even if neither is auto
        // renewing
        mSubscribedToRefSub = (refsub != null && verifyDeveloperPayload(refsub));

mSubscribedToRefSub returns true while I was expecting it to return false. However mAutoRenewEnabled does return false but is that a valid way to check for active subscriptions since we need to keep the app active for the user until the end of the subscription period.

Upvotes: 1

Views: 734

Answers (2)

Ravin
Ravin

Reputation: 21

Thanks for the reply. Turns out that for mSubscribedToRefSub to start returning false it can take up to a day from when the Play store shows that the subscription has been cancelled. So it does work but not right away.

Upvotes: 1

Terry
Terry

Reputation: 669

Yes, this is correct.

https://developer.android.com/google/play/billing/billing_subscriptions.html#cancellation

It says that canceling subscription means that user should be able to enjoy the subscription till its expiration date (as there will be no refund), but this subscription will not be renewed after that time.

As the expiration time is still the same, the subscription will be returned in getPurchases() method, but the auto-renewal field will be false.

So, till the time subscription is returned by this method, you must provide its content/feature to the subscriber.

Upvotes: 0

Related Questions