When purchasing auto-renewable subscriptions in the AppStore sandbox, the subscriptions don't automatically renew and terminate after the first period.
I don't know why, but this was working before. What I do is run a cron every few minutes that revalidates the stored receipt and fetches the latest_receipt_info.expires_date_ms with the biggest timestamp value.
According to Apple's documentation 1 month subscriptions should renew 5 times every 5 minutes.
Is the sandbox just flaky or is this expected behavior?
Update
I created a new sandbox user and now it renews again correctly. What did I miss?
You can not reuse the same sandbox user after the ends of the 5 renewals periods, you will need to create a new one to test again. They can only used for one test cycle.
Related
I am working on implementing iOS subscriptions. If a new subscription is purchased for a new test user in most cases the subscription will be renewed 5 times and is than canceled.
However, in some cases the subscription moves to is_in_billing_retry_period = true after the initial purchase and is stuck in this state forever.
I know that is_in_billing_retry_period is used to implement a grace period and than in production Apple will try to recover the the subscription (e.g. solve any billing issues) and it is great that this use case can be tested.
BUT is there any logic on which purchases will renew and which will get stuck in is_in_billing_retry_period? Or is this a random behaviour?
It is quite hard to test special use cases if one cannot specify which use case will be performed next by the sandbox...
I am facing issues with my auto-renewing subscription for an iOS app that offers auto-renewable subscription.
The Subscription Status URL is at times, not being called when the subscription is renewed. This is making it difficult for us to track the user's subscription status. Funnily, this behaviour is completely arbitrary at times it is called and everything works smoothly, but at times it is not called at all.
Also, once the user's subscription is renewed, at times the user is not charged on his/her credit card instantly. Is this behaviour normal?
You have to follow basic rules for subscription based application.
Whenever you buy any auto renew subscription, in success verify your receipt and verify expiry date.
On every application launch very receipt and verify subscription. On depending result you can notify your server.
In sandbox environment for monthly subscription it will auto renew for every 5 mins. It will auto renew for 5 times. So you can check your test cases. After that it will be expire.
In real world case subscription will auto renew before 24 hours of renew date. So if user cancels subscription before that.
If you are using SwiftyStorekit than it will be very much easy for you to handle each and every steps. Let me know you if you want more coding approach in this case.I will share example code details if you want.
The Subscription Notifications are pretty unreliable and the descriptions of how they work aren't very clear. For example:
RENEWAL events aren’t sent when a subscription renews. ... RENEWAL
is sent when a subscription has expired, then later, the user starts
the subscription again.
CANCEL does not mean a user normally cancelled their subscription. It only is sent when a user cancels their subscription via customer
support. This is also known colloquially as a refund.
Source: RevenueCat (Disclaimer: I work there)
A college of mine has implemented iOS in-app purchasing on a auto-renewing monthly basis. I am taking over the code base and want to test it is working. I know the purchasing is wokring but the auto-renewing is what I am worried about.
I have set up a test user and read the Apple documentation that says in sandbox mode, a month is 5 minutes in the sandbox.
However I am not getting any post back from Apple after 5 minutes? should I?
In the AppDelegate I have
inAppPurchase = [TFInAppPurchase new];
[[SKPaymentQueue defaultQueue] addTransactionObserver:inAppPurchase];
[inAppPurchase updateAvailableProductsCache];
I am expecting after 5 minutes, it to fire of a notification or something?
In the iTunes development guide, there's list of how long auto-renew subscriptions last in sandbox mode:
Sandbox Testing Your In-App Purchases
You are required to test your in-app purchases in a sandbox environment before you submit them for
review by Apple. You must first sign out of your iTunes Store account
from your test device Settings before attempting to use the sandbox
environment. If you mistakenly use your test-user-account credentials
to log in to a production environment on your test device (instead of
in to your test environment), your account credentials become invalid
and cannot be used as a test account again. For more details on how to
avoid mistakes during test account use, see “Using Test User
Accounts.”
When testing auto-renewable in-app purchase subscriptions in the
sandbox environment, the duration times will be compressed to allow
for more streamlined testing. Additionally, a sandbox subscription
will only auto-renew a maximum of 6 times. After the subscription has
auto-renewed 6 times, it will no longer renew in the sandbox. The
compressed duration times are as follows:
Actual duration Sandbox duration
1 week 3 minutes
1 month 5 minutes
2 months 10 minutes
3 months 15 minutes
6 months 30 minutes
1 year 1 hour
There is no notification. You keep track of it yourself (the duration). You get a receipt with the original transaction that you save. Use this to verify (perhaps on launch each time) that the user's subscription is still active.
No notification will be generated by apple.
You have to save the recipes on server or device by using nsuserdefaults or keychain.
you have to track the duration by yourself.By caluclating
Compare the product identifier in question to the product identifier of each in-app purchase receipt.
If there is a receipt that matches, validation succeeds. Otherwise, validation fails.
When validation succeeds, your application enables the purchased functionality—for example, by downloading content or adding features. When validation fails, your application simply does not enable the functionality.
I have integrated auto renewable subscription and its done, but how do i test when it expires because it requires atleast 7 days for subscription expiry.
I need to test it by specifying 5 mins or any specific time. We can't wait for 7 days to get subscription expired in sandbox.
Thanks in advance
In the sandbox, all auto-renewing durations have been shortened to just a few minutes (and they only renew 5 times). So you don't have to wait 7 days to test for renewal. You should test frequently in the sandbox, to see if there are any new receipts.
I am looking to build a ios application that will use an auto-renewable subscription on a monthly biases. We will be using some VOIP features that we will be charged monthly for. My question is, how can we be notified when a user cancels a subscription in IOS, so that we can cancel the users VOIP telephone number with our provider.
You will need to verify the receipt the same way you do for regular In App Purchases, but obviously you will do this every time the subscription period expires. Check out the documentation on this, Verifying an Auto-renewable Subscription Receipt
So based on this, it appears you will need to setup your server to check for a valid subscription every month (cron job?). This will allow you to cancel the VOIP number in your system if the subscription is no longer valid. Your app would be responsible for verifying a subscription is still valid when it is opened or the user attempts to access features that require a subscription.
Updated For Comment
The sandbox is supposed to return expiration dates in the following scheme.
This is from page 164 of the iTunes Connect Developer Guide
If it is not working this way you may want to file a bug report.
Also, please not the following from Apples IAP doc:
Additionally, a sandbox subscription will only autorenew a maximum of 6 times. After the subscription has auto-renewed 6 times, it will no longer renew in the sandbox.