Reputation: 13267
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?
Upvotes: 4
Views: 3373
Reputation: 2579
The renewal process begins with a “preflight” check, starting ten days before the expiration date. During those ten days, the App Store checks for any issues that might delay or prevent the subscription from being automatically renewed—for example, if the customer no longer has an active payment method, if the product’s price increased since the user bought the subscription, or if the product is no longer available. The App Store notifies users of any issue so that they can resolve it before the subscription needs to renew, ensuring their subscription isn’t interrupted.
The answer to your first question is 10 days. You will not miss any and it is handled by the App Store.
During the 24-hour period before the subscription expires, the App Store starts trying to automatically renew it. The App Store makes several attempts to automatically renew the subscription over a period of time but eventually stops if there are too many failed attempts.
It is possible for it to renew after a previous failure. For instance if the user's payment information becomes invalid. This is why they begin ten days early. The App Store will prompt the user to correct their information. If they complete this 24 hours prior to renewal everything will be okay.
If it stops "after too many failed attempts" then it won't try again until the next subscription period.
Also of note, is that changing the subscription price does not necessarily disable a subscription.
Upvotes: 5