I'm making an app with buy some subscriptions. I want to get Expired day of Subscription, when I finish buying a subscription. But I haven't gotten Expired Day. Help me get Expired Day of Subscription!
Related
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.
According to the billing subscriptions documentation, there is a possibility of triggering a manual renewal before the current subscriptions has expired.
For eg. If I invoke the same purchase flow on a particular monthly sub 2 times in a row, the second one will fail with the error 'You have already subscribed to xxx'. I am expecting it to succeed and add an additional month to the expiry date.
Is there a way of manually renewing IAP before the expiry date?
the manual renewal will happen with subscription recovery.
I have an app in the playstore for my website, that offers a monthly recurring subscription, and on my backend I am both granting that month of premium usage and recording the fact that another payment occurred whenever the expiry time runs out on the last receipt and I re-query the Google subscription to check it is still active using https://developers.google.com/android-publisher/api-ref/purchases/subscriptions
There are other forms of payment on my website and apps, so I found this approach was working best. However recently I noticed my system had recorded too many payments compared to what was reported by Google itself.
It turned out that at renew time when I re-query the subscription, Google was returning that it was still active but expired in 1 day, instead of in ~30 days. My system would record that a payment must have occurred and then check again in 1 day (which this time would give the correct expiry time), and then again record that a payment must have occurred when Google again reported it was still active.
For example:
20th February - Initial purchase on app, app tells server the receipt etc. Expires in 30 days.
21st March - The expiry time is up so server re-checks status and Google says "expires March 22nd".
22nd March - The expiry time is up so server re-checks status and Google says "expires April 21st" (this is what it should have said last time)
21st April - The expiry time is up so server re-checks status and Google AGAIN says it only expires in 1 day, on the 22nd of April
etc
I am at a loss as to why Google is reporting the wrong expiry times once a month. I do not have any free days / trial period set up for my IAP subscription. As long as Google reported the correct expiry times then I would have recorded the payments correctly. But if the expiry time is not reliable, how can I tell if a payment has actually occurred?
The subscriptions resource returned by the above API call does not return the orderId of the most recent payment. I can't find a way to link the receipt I have stored server-side with its purchaseToken to any billing information of subsequent renewal payments.
Is there a way to link a receipt/purchaseToken stored server-side to actual payments that are occurring using a Google API? How can I get the most recent orderIds?
But if the expiry time is not reliable, how can I tell if a payment has actually occurred?
I am working on exactly the same problem and have the same observation.
It seems that even if you have no Grace period, it will behave like you have set grace period to 1 day.
Since you don't have grace period, my suggestion is to check the newly queried expiry time against the previous expiry time (you need to store that somewhere).
If it differs by around 1 month, then you can consider that a successful payment. Otherwise, the difference should be around 1 day and it's Google's grace logic at work (probably).
Take note that the time the expiry time varies (i.e: if you first expiry is on 21st March 12:00:00, the second expiry can be after, like 21st April 13:12:32), so you shouldn't use sharp check (i.e diff == exactly 1 month).
Here is an example from Google merchant history. The Date column is approximately equal to the expiry time.
Is there a way to link a receipt/purchaseToken stored server-side to actual payments that are occurring using a Google API? How can I get the most recent orderIds?
You can get the client to send both orderID and purchaseToken as part of the payload, then link them on server.
That seems to be the only place with knowledge of both, for now.
I'm using the In-App billing v3 in my Android app for subscriptions.
Now I'm testing it in real scenario, I bought a month subscription a month ago and now, after a month I received an email of renewal charge.
It's a couple of hours (about 7) but the method getPurchases() is still returning the information about the old purchase bought a month ago.
I readed an information about local caching of purchases data, but I didn't find an information how long is the cache valid?
I understand that device can be offline, so the cache cannot be updated, so let's assume that my device is constantly connected to Internet.
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.