How determine from client side if Google Play Billing subscription is expired - android

I have implemented Subscriptions in mine Android app, and wondering how to check expired subscription. As I understood, expired subscription should not be returned in getPurchases() method.
The problem is - I tested 1 month subscription using test account (which renews subscription every 5 minutes, as described here https://developer.android.com/google/play/billing/billing_testing#testing-subscriptions), and after expiration time I still recieved that purchase in getPurchases(), even after 1 day. However, if I manually tried to subscribe one more time, Play Market didn`t refuse, and everything worked fine.
Also, when I was selecting 'decline payment' in subscription settings, it dissapeared from purchases list, as it supposed to be.
Thanks in advance.

I didn't understand what do you mean by "renews every 5 minutes".
Once you subscribe to Google play to any app/service, it will be available until the end of the subscription.
For example:
I purchased a subscription with an APP for 6 months.
I went to Google Play after 2 days and canceled my subscription but the app will still see that I am subscribed for the remaining 6 months because I already paid the subscription fees.
It's not something that you can handle from Google Play :)
Hope this helps.

Related

How to test InAppPurchase Subscription renewal in sandbox mode

I am using InAppPurchase to sell subscription to users with one month plan.
Setup is done and i can test Purchase flow, but renewal is not working in sand-box mode.
I am using billing library version 4
implementation 'com.android.billingclient:billing:4.0.0'
After successfull purchase while validating receipt on server side getting autoRenew param in json with value blank. After 5 min plan is expired as describe in doc, but as per doc auto renew will expires after 6 times. In my case after first purchase auto renew not happening.
Can any one help me in this where i am wrong in this.
I already spent 4 days in searching for this issue.
Thanks in advance
From your screenshot I'm deducing you are in India.
A few months ago, Google has announced that it would pause new signups of auto-renewing subscriptions for users in India:
Subscriptions will continue to be available as single access passes that provide users a single billing period of access (eg. 1-month access). At the end of the billing duration, Google says users will need to sign up again in order to continue their subscription.
source: https://www.xda-developers.com/google-play-suspend-free-trials-auto-renewing-subscriptions/
Maybe you should try to test on another market.

google android In-app purchase testing issues

My app is published in alpha, and allows for purchasing a yearly subscription with a 7-days trial period.
I just tested the purchase process with a test account (declared as such in dev console).
The purchase went ok, and the user received a mail confirming his purchase. This mail is full of mistakes:
1) the price is without tax, which is confusing
2) It says the trial-period will expire tomorrow, instead of in 7 days (we are on Feb 27):
You have signed up for a free trial subscription from xxx on Google
Play. Your trial will end on Feb 28, 2015. You will be automatically
subscribed for €15.83/day at the end of your trial unless you cancel.
3) Funnily enough, it says that after the trial period, he will be charged DAILY, instead of yearly:
By subscribing you authorize us to charge you the subscription cost
(currently €15.83/day) automatically, charged daily to the payment
method provided. You can cancel at any time
Moreover, I couldn't find a way to cancel the subscription. I went to the wallet account of the user, no transaction there. Same thing in the merchant wallet account from my side. How am I supposed to cancel the transaction and try again eventually?
The only good point is that my app and google api (V3) recognizes that the user has purchased the subscription.
Maybe it's just because I declared the user as a test-user in google-dev console?
Thanks in advance for any input or advice.
The reason why it says 'day' instead of year is answered here:
Android In App BIlling v3 - Wrong Subscription Trial Period
This is a normal response. I guess you're testing with an account
added as a tester to Google Play account. Test subscriptions are valid
for 1 day and get cancelled after 1 day.
Quoting the official docs
http://developer.android.com/google/play/billing/billing_testing.html
Note: Test subscription purchases recur daily, regardless of the
product's subscription period.

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.

testing subscriptions - can't cancel

I have my in-app subscription working using a second test account. Now when I check inventory using queryInventoryAsync the subscription shows up as expected.
So now I want to do some more testing. I want to cancel the subscription and then when I know that works, I want to test again.
However, when I go to Google Play -> My Apps on the same phone as I used to buy the subscription, it shows no subscriptions! So I can't cancel it. What is wrong?
Also, how can I test expiration of subscription and make Google think time has passed.
Thanks,
Gary
Turns out that Google does not support testing of subscriptions. You have to use real charges.
To cancel the subscription have to go to the Google Wallet web. It's the only way, you can't do it in-app.
To testing process. You can use a subscription with trial time, in this way you haven't to pay until this trial time finish and you can test at least the purchase flow.
Also you "only" have to wait a week to see the subscription expired, and without make a refund if you had cancelled before.

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