Android Subscription cancellation -> How to be informed and how to test? - android

I've created a monthly subscription (7 days trial included) on Google Play.
I just bought
it and the callback via onPurchaseStateChange worked perfect. But afterwards i cancelled
the subscription purchase.
I still (after 10 hours) get the info that the subscription is purchased not canceled.
Will it be canceled after the trial period?
Or how will this info be transfered?
And how can i test the cancellation behavior?
Thanks for response in advance.
Regards,
Jochen

Yeah, it's kind of confusing. Here is the documentation that explains why it happens:
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 cancelled 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).
So, even if you cancel the subscription, it's still valid until the end of the current cycle.

Will it be canceled after the trial period?
No, if it was canceled by user when trial period ends.
Or how will this info be transfered?
When your subscription expires(or canceled) you will not get any information about it in Inventory. So the size of inventory will be zero and thus you can determine that subscription(any or all) was canceled.
And how can i test the cancellation behavior?
Create a test SKU, set the price to 1 USD, and test it. There is no other way, and it's worth it. Rather then spending hours on searching for no results.

Related

Android In-App Subscription PurchaseState is always 0

In my android app using in-app subscription monthly plan. I have purchased a subscription product with test account. After one hour I cancelled it manually from my phone.
After I query using inventory.getPurchase(monthlyplan), I always get purchase state is 0.
I waited more than one day; still getting response of purchase state is 0. Can any one help me on this?
You may want to check this document - Subscription Cancellation:
Users can view the status of all of their subscriptions and cancel them if necessary from the My Apps screen in the Play Store app. Currently, the In-app Billing API does not provide support for programatically canceling subscriptions from inside the purchasing app.
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).
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. Alternatively, you can use the refund and revoke API to revoke each subscriber's subscription (one by one) and refund their subscription payments. Removing content that any subscriber is entitled to access will result in penalties. Please see the policies document for more information.
There are some good insights regarding the following (also found in the same document):
App uninstallation
Refunding and revoking subscriptions
Here is a related SO question that also talk about cancelling subscription in-app.

How to determine if user cancels Google Play subscription?

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!
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.
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

In-app subscriptions remain "purchased" after cancellation

I know it has been asked a few times here but still there's no answer explaining why it happens:
Buy the subscription. (subscription is added in my beta draft of the app in the developer console)
Cancel it in my phone's google play account
Query the inventory and get:
{
"packageName":"",
"productId":,
"purchaseState":0,
"autoRenewing":true
}
Obviously the purchase state should be 1 (Cancelled). I tried querying after 12 hours - still same. Am I missing something?
Might be this reason..
From Developer Docs -Subscription Cancellation
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.

Is this a bug with Google's In-App Billing Service?

I am implementing an in-app subscription in an Android app. In the developer console I have a subscription item with a 7 day free trial. While debugging, I purchased this subscription. A couple days later, before the 7 day trial is over, I cancelled the subscription from the Play Store | My Apps | Subscriptions.
Many days later, long after the 7 day trial period, in my code when I get the owned subscriptions (with inAppBillingService.getPurchases()) it still says I own the subscription. Since I cancelled it during the trial, I am not billed for it, but also, I no longer own that subscription. As far as I can tell, this is a bug with Google's In-App Billing Service. Any one know how this bug can be reported to Google so it can be fixed? As it is right now, customers can purchase my subscription and then cancel it during the trial period. They then get to keep using the subscription because Google says they own it. This is a MAJOR BUG.
I went ahead and tested this in my app. Using the sample app, I call the method launchSubscriptionPurchaseFlow() from the IabHelper class to start the subscription purchase. After the user confirms it, I get the purchase validated and handle the UI update on OnIabPurchaseFinishedListener.
I also check every time on my activity's onCreate() method if the user has the purchased items and subscriptions. This is done with the method queryInventoryAsync() of the same class. In my case, after canceling the subscription and waiting a few hours after the 7 days trial period elapsed, the user no longer had the subscription. You can test this by checking in the Purchase object if myPurchase.getPurchaseState() != 0. Possible purchase state values are listed in the documentation.
Finally, note that the cancellation will not be propagated immediately so it might take more than 7 days for that to go through. And it will take at least 7 days regardless of when the user cancels it. According to the documentation:
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 cancelled 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).
Hope that helps.
Now that a month has passed, I have more info.
Clearly what I was seeing in October IS A BUG in Google's code.
With absolutely NO change to my code, everything works as it should in the code deployed from the play store. This was true for alpha, beta and production.
It did not work as expected for code installed on the device from Eclipse - hence the Google BUG.

When do android app get the "Expired" status after canceling the subscription during the trial period

There is a "Subscription with Free Trial" in my android app, and the BillingService would get the Purchased status after buying subscription product.
But, the BillingService does not get the Expired status after canceling the subscription.
However, accroding to Android Developer,
"If necessary, the user can cancel the subscription at any time during
the trial period. In this case, Google Play marks the subscription as
expired immediately, rather than waiting until the end of the trial
period."
but My app does not get the status.
I wonder that When does android app get the "Expired" status after canceling the subscription during the trial period.
I've noticed this too. In my case the purchase state only changed at the end of the (7-day) trial period even though I cancelled within minutes of purchasing the trial subscription.
I'm currently waiting for another cancelled trial to expire - it's been 3 days now and the purchase state is still 0 ("purchased successfully").
Update:
So it seems you either need to restore transactions periodically (Google says you should not do this "because of performance impacts") or you need a web-server with code to check the subscription details using the the server-side API http://developer.android.com/google/play/billing/v2/billing_subscriptions.html#play-dev-api. Your app would then query your web-server which would only check with Google's services when the expiry date has been reached.
I have tested this case in a non-test environment, i.e. productive environment.
I received a ACTION_PURCHASE_STATE_CHANGED notification with EXPIRED state some 4 hours after cancelling the subscription. (I've cancelled the subscription a few minutes after the purchase. Trial period is 7 days)
Trying to re-purchase the subscription after the EXPIRED notification returned "Already owned" a couple of times, and after that I was able to re-purchase (without the trial period, as documented).
I do not have the Google server API implemented, so I don't know what would the status be. However, on the Merchant site, the order and the Order CSV download show the item as CHARGED.
So, what has changed since the previous answer?
Productive environment vs Google test environment
Possibly a Google bug fix
Once I implement the Google server API query, I will update this answer.
UPDATE:
I have implemented the Google Server API check, and it shows correctly that the subscription was cancelled a few minutes after the purchase. This API check was done 3 days after purchase, well within the 7 days trial.
My conclusion at this point in time is that user cancellations within the trial period are handled correctly by Google.

Categories

Resources