How to determine if user cancels Google Play subscription?
Asked Answered
A

2

28

About to build a subscription product into our Android app, but a little unclear on the best way to know about canceled subscriptions. The only way we are planning on letting the user cancel is for them to go to Google Play Store and explicitly cancel, but in this case, our backend won't be notified.

The Google Play Developer API docs explicitly say you must not query the API for the status of all subscriptions so how are we supposed to know which users have cancelled their subscription?

Any help much appreciated!

Alatea answered 4/6, 2016 at 23:27 Comment(0)
F
8

It looks like it's now possible to receive server-side notifications about subscriptions changes (renewal, cancellation...):

The In-app Billing API provides server push notifications that give developers the capability to monitor state changes for Play-managed subscriptions.

See this page for more details: https://developer.android.com/google/play/billing/billing_subscriptions.html#realtime-notifications

Fanjet answered 19/10, 2017 at 14:19 Comment(2)
The anchor realtime-notification no longer exists. Similar information can be found here, though: developer.android.com/google/play/billing/…Silda
But in that case, How should I get to know that which user cancels a subscription (means the user id of our server)Boner
B
22

According to In-App Subscription documentation there is no mechanism to detect when the user cancels the subscription. Since it is not canceled immediately. Instead it waits for the end of the cycle for the subscription to expire.

Excerpt from document (source)

When the user cancels a subscription, Google Play does not offer a refund for the current billing cycle. Instead, it allows the user to have access to the canceled subscription until the end of the current billing cycle, at which time it terminates the subscription. For example, if a user purchases a monthly subscription and cancels it on the 15th day of the cycle, Google Play will consider the subscription valid until the end of the 30th day (or other day, depending on the month)

The app won't receive any kind of notification when user cancels the subscription.

The behavior of subscription is whenever you query the inventory in the app SKU will be returned if subscription is valid. When the subscription expires the SKU won't be returned when you query the inventory.

According to the documentation in this link

It is okay to run a batch query whenever subscription is nearing the end

Excerpt from document (source):

Query for subscription status only at expiration — Once your server has retrieved the expiration date of subscription tokens, it should not query the Google Play servers for the subscription status again until the subscription is reaching or has passed the expiration date. Typically, your servers would run a batch query each day to check the status of expiring subscriptions, then update the database

The following server api lets you query the subscription status:

https://developers.google.com/android-publisher/api-ref/purchases/subscriptions#resource-representations

The variables autoRenewing and cancelReason will let you know if the subscription has been canceled.

By using the above API you would be able to implement a system wherein the subscription nearing expiration can be queried for status and then determine whether they are canceled or not.

Full details for subscription cancellation can be found at this link.

Note:
Documentation states that you should continue to provide the content as long as the user has valid subscription. If you are planning to deny access to the content if someone canceled the subscription will go against the Google Policy

Excerpt from document (source)

Important: In all cases, you must continue to offer the content that your subscribers have purchased through their subscriptions, as long any user is able to access it. That is, you must not remove any content while any user still has an active subscription to it, even if that subscription will terminate at the end of the current billing cycle.

Brey answered 14/6, 2016 at 10:31 Comment(5)
Thanks Anirudha. If a user has a subscription which renews once per year, but for which they pay monthly, should we query the API for expired subscription monthly on their billing date?Alatea
I don't think that Google Play allows you to pay monthly for yearly subscription. If it does can you provide the link to it ?Brey
I think you're right, just saw this: "For monthly and annual subscriptions, billing cycles will always match subscription cycles, based on the purchase date." on developer.android.com/google/play/billing/…Alatea
I dont know if it is correct for real subscriptions but when I test with test account and cancel the subscription, even after expiry date, it is still returned.Paver
Here are a few resources for more recent instructions for getting more user subscription data, including how to implement Real-Time Developer Notifications (RDTNs): developer.android.com/google/play/billing/… An example app: github.com/android/play-billing-samples/blob/…Ilianailine
F
8

It looks like it's now possible to receive server-side notifications about subscriptions changes (renewal, cancellation...):

The In-app Billing API provides server push notifications that give developers the capability to monitor state changes for Play-managed subscriptions.

See this page for more details: https://developer.android.com/google/play/billing/billing_subscriptions.html#realtime-notifications

Fanjet answered 19/10, 2017 at 14:19 Comment(2)
The anchor realtime-notification no longer exists. Similar information can be found here, though: developer.android.com/google/play/billing/…Silda
But in that case, How should I get to know that which user cancels a subscription (means the user id of our server)Boner

© 2022 - 2024 — McMap. All rights reserved.