I am trying to enable users to buy books using Apple's auto-renewable in-app purchases. I keep a copy of the subscriptions on my server so that the user can access his/her books across multiple devices and via the web.
I am trying to figure out how to keep the subscriptions on my server up-to-date when they are auto-renewed by Apple. I was thinking of having a cron job run once an hour that would run a PHP script. This script would select the subscriptions that are going to expire within the next hour from my database and check the subscription receipts with Apple to see if they have been auto-renewed (i.e. there is updated information in the latest_receipt_info
field of the returned information). I can then update the database with information about the auto-renewed subscriptions. If I can't find any new information about auto-renewal in Apple's response dictionary, the subscription will simply be left to expire.
Will all subscriptions always be auto-renewed at least an hour before they expire (will I miss any)? Is it possible for a subscription to auto-renew after it has expired (or will the user have to purchase a new subscription)? Is there any flaw in my thinking?