9

I'm implementing auto renewable subscriptions in my app and I wonder if there is a way to simulate when a subscription period runs out and a new transaction is created.

The app is connected to a online service that always keeps track of the users and if they have "premium access" or not. As understand i, there are two ways to detect when a transaction is made.

  1. The app is launched and updatedTransactions: is called in my PaymentObserver as a SKPaymentTransactionStateRestored. I then, from the app, send this information to the server which updates the subscription.

  2. I regularly check the App Store API and compare the "latest receipt" with the one in my database. If there is a new one, a transaction has been made and I extend the subscription.

Either way, I need to simulate that the subscription period runs out and a new transaction is made by the App Store. How do I do this?

Jilouc
  • 12,684
  • 4
  • 46
  • 43
oskob
  • 1,386
  • 1
  • 11
  • 27

4 Answers4

7

The sandbox environment automatically simulates subscription renewal. 1 year subscriptions will renew every 1 hour. 1 month subscriptions appear to renew every 5-6 minutes.

Each subscription appears to renew 5x. At that point, the subscription is cancelled. Each renewal triggers a restored transaction sent to the client app.

This is all based on my experience. I cannot find any official documentation for it from Apple.

glutz
  • 1,889
  • 7
  • 29
  • 44
  • 3
    This is all documented here (developer login required): http://itunesconnect.apple.com/docs/iTunesConnect_DeveloperGuide.pdf – TomSwift Aug 24 '11 at 22:38
3

Are you sure you need to simulate this? I think you'll find that in the sandbox, the subscription lengths are made very short so that all you have to do is get a cup of coffee or something and they will expire and then you can test what happens.

the amount of time varies depending on the length of the subscription, but I think the 7 day subscription expires in just a few minutes in the sandbox.

Paul Bruneau
  • 1,026
  • 1
  • 9
  • 15
  • right, a 7 days subscription last *3 minutes* in the sandbox env. – yonel Aug 31 '11 at 11:57
  • 2
    One caveat: Subscriptions will only auto renew 5 times. After that if you purchase they will no longer auto-renew. You have to create a new test user to do it! – Jarson Mar 10 '12 at 00:38
1

Actually the renewal doesn't seem to work in Sandbox. It looks like you're always into the buying process. Auto-renewal is supposed to be "shadowed" as AppStore will automatically re-conduct it until the user explicitly "cancel" it. In the Sandbox, each 5 minutes you have to purchase again.

Finally, there's a bug in the "You Already purchased that in-app" as it is supposed to send a proper transaction but it just sends an Error code.

nembleton
  • 2,392
  • 1
  • 18
  • 20
0

Actually, I experience the renewal in the Sandbox to be very unpredictable. Sometimes it works as described, sometimes it works very differently, sometimes it doesn't work at all (saying that as a developer with an app in store that actually uses In-App-Purchases with autorenewable subscriptions, apparently successfully in production). Just at the moment I have a monthly subscription in the sandbox that has an original purchase date from 27 hours back and an expiry date of three hours back. I really wonder how you are supposed to test this if the responses are absurd like that.

Katlu
  • 496
  • 6
  • 14