How to test the "renew" component of auto-renew subscriptions in iOS App Store Sandbox?

11,862

Solution 1

Copied from the Apple's Developer Forum, for those not willing to goto the forum...

Figured it out (but not thanks to the Apple docs):

1 month subscriptions auto-renew every 5 minutes. So far so good. They auto-renew 5 times and then they stop, so after 25 minutes you'll get the 21006 error. However even when repurchasing the same subscription it will NOT auto-renew again on the same test account since it has already auto-renewed 5 times. So if you want to test renewal and you have been messing with these subscriptions for a while you need to create a new itunes connect test user. This is very annoying honestly and it would be a lot easier if we could just reset the entire purchase history of a test user account. Also putting all in-app test information in the Xcode documentation would be a lot better as opposed to spreading it over Xcode docs/iTunes Connect doc/people figuring stuff out themselves

Hope this helps.

Solution 2

This conversation in the Apple dev forums may shed some light on this issue for others who discover this post: https://devforums.apple.com/thread/105350?tstart=0

Solution 3

@Lata Sadhwani, App developer

For testing auto-renew subscriptions, the expiration time is 5 minutes in sandbox (at least for the monthly subscriptions, not sure if this is different for different periods). So when testing an auto-renew subscription in sandbox, it should auto-renew every 5 mins and you know they are working correctly.

But there is one problem. These subscriptions auto-renew only 5 times (i.e. the purchase happens 6 times). After that you'll get an error when verifying the receipt. So if you want to test after that, you will need to test with another IAP test account (yes it is a pain testing, especially if you have been doing this for quite some time!)

To check if a subscription has been cancelled or is valid, your receipt verification code will need to parse the response from Apple servers and they say you should verify each receipt. If the subscription has expired or has been cancelled, the appropriate error code will be returned (a non-zero status). If it has been renewed by a user, the most current receipt is returned by the Apple servers.

Share:
11,862
esilver
Author by

esilver

My apps: http://www.perrystreet.com

Updated on July 05, 2022

Comments

  • esilver
    esilver almost 2 years

    Folks,

    I am attempting to verify that auto-renew subscriptions are actually renewing in the sandbox environment. First, it appears that auto-renew subscriptions in sandbox are only valid for 5 minutes. Makes sense. I expect that if I wait for five minutes, then make another call to

    https://sandbox.itunes.apple.com/verifyReceipt

    With my receipt data, I should see the subscription renewed with an expiry date another five minutes out.

    Unfortunately that is not the case. All I see is a response with latest_expired_receipt_info and a status of 21006, which means "This receipt is valid but the subscription has expired" according to the Apple docs.

    Can anyone tell me if they are able to test auto-renew subscriptions end-to-end, including this renew component? Or do I have to launch this app and cross my fingers that prod will work as advertised?

    Alternatively, is there some sort of client-side magic/API call I have to run prior to re-posting my data to the verifyReceipt URL?

    There was some discussion on this topic here, but it's not clear to me if I can/should expect to be able to re-verify subscriptions entirely on the server side by posting to the verifyReceipt URL or if I have to do something on the client side too.

    Thanks!