9

I am implementing an app that will have an in-app subscription purchase. The subscription is renewed on a monthly basis. When a user purchases the subscription, they get a free 30 day trial. I understand that I have access to the purchaseDate value from the JSON that is returned, however I have a few questions about this:

When a person's subscription renews, does the purchaseTime / purchaseDate get updated to the date/time of the renewal? Or does it always remain the original purchase date?

I am trying to figure out the best way to cache this locally in the application so as to only have a check using getPurchases a couple of times per month around the time of renewal, are there any good examples or best practices I could follow?

Please don't respond by posting the documentation link. I know where to find that and have read it already :)

2 Answers2

0

The getPurchases() method mentioned here only pulls non-expired purchases. Therefor, if your app notices that a user does not have a purchase (no purchases returned from 'getPurchases()', but they DO have purchase info (has_purchase, purchase_token, etc..) in your app's DB, then you found an expired purchase, so remove all purchase info in the DB for that user.

Hope that helps.

user3386826
  • 327
  • 8
  • 19
-1

Here is my current guess on this I haven't been able to find a good doc either.

I believe the simple answer is that the purchase date is the original purchase date not the date of the renewal.

In other words if the subscription started on March 1 and you do getPurchases in July the purchase date will still be March 1 even though there have been a few renewals.

You can tell the subscription is active with getPurchaseState() = "0" (Purchased), "1" = Cancelled, "2" = Refunded.

To know the expiration date use the Day of the Month from the Purchase Date and find the next occurence of that Day of the Month. For example if today is July 15th and the getPurchaseState() = "0" then the expiration date must be August 1.

All of the above is a bit of guesswork. I wish I could find a good doc on this too.

  • This method I think neglects the state where a user cancels, but still has time left on their subscription. I believe the only real way to do this is to query the Google Play Developer API and get the subscription information there. – Brian Mar 07 '16 at 05:32
  • Its not ignored, its more like we couldn't find a good answer to the question about exactly what information is available. Can you be more specific about the meaning of "query the Google Play Developer API "? Maybe you could show a couple lines of code that might be used. To be able to deal with a cancel you have to know does the subscription information remain available after the cancel? How long does it remain available? – Brian Best Mar 08 '16 at 14:36
  • The API you need to call to Google to get the information is listed here: https://developers.google.com/android-publisher/api-ref/purchases/subscriptions#resource-representations. If you call the "Get" method, you will be returned that resource which displays the start time and the expiration time. The start time is the very beginning of the sub, and expiration is the time it ceases to be active. If this still makes zero sense (I was confused for a long time), then I can do a better writeup in the answer here. Google's docs are horrendous. – Brian Mar 09 '16 at 23:30
  • Thanks, this looks like a possibility. If this turns out to be what is needed to get the dates there really should be a link to it here: http://developer.android.com/google/play/billing/billing_integrate.html#Subs – Brian Best Mar 11 '16 at 00:38