4

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?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Jack Humphries
  • 13,056
  • 14
  • 84
  • 125
  • This is handled via your app and is addressed in the programming guide- https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html#//apple_ref/doc/uid/TP40008267-CH7-SW6 – Paulw11 Dec 31 '14 at 06:04
  • @Paulw11 It appears that there is a way to do this server-side (http://stackoverflow.com/questions/18161036/how-to-detect-and-verify-a-renewal-for-an-auto-renewable-subscription). I'm just concerned about how far in advance I am able to check and if I need to continue to check after the subscription has expired. – Jack Humphries Dec 31 '14 at 06:06
  • 1
    Apple recommends *all* purchase processing be done server side. Any time you do it on the phone, you're leaving your app wide open to have users bypass in app purchase and get a free subscription. Server side processing of purchases is the only way to do it properly. – Abhi Beckert Dec 31 '14 at 06:20

1 Answers1

5

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.

Sam
  • 2,579
  • 17
  • 27
  • Great answer, thanks! You said that if there are too many failed attempts, Apple won't try to renew until the next subscription period. Does this mean that a subscription that has expired could become active again? – Jack Humphries Mar 25 '15 at 00:27
  • @JackHumphries Have you figured out what to do if the subscription fails to renew after too many failed attempts? – daniel Jul 06 '20 at 18:21