How to Test iOS In-App Purchases with Sandbox
Testing in-app purchases in the sandbox environment is a crucial step in ensuring that your app is functioning properly before submitting it to the App Store. The sandbox environment simulates the App Store environment, allowing you to test the entire process of purchasing an item in your app without actually charging your users.
Prerequisites to test iOS in-app purchases
The sandbox environment provided by Apple enables the testing of in-app purchases without any actual charges using test accounts. This environment leverages the App Store infrastructure but does not process actual payments. Rather, it returns transactions as if the payments were successfully processed.
There are a few things you should consider when you start testing your in-app purchases.
- To test in the developer sandbox, the app needs to be built as a developer build in Xcode.
- In-app purchases can be tested without prior approval from App Review.
- Device provisioning is limited to 100 per device type and a total of 500 devices to prevent widespread distribution outside the App Store.
- Subscriptions renew at an accelerated rate in the sandbox environment.
- No receipt is available in the sandbox environment until a purchase is made.
Add a testing account to App Store Connect
To start, add a testing account to App Store Connect.
- Go to Users and Access and click on Sandbox Testers.
- Click the add button (+).
- Enter the necessary tester information and click on Create.
- You can use the “+” symbol for the email to prevent you from creating a new email for every user.
- Please note that once the Sandbox Apple ID is created, the tester’s name, email, and password cannot be edited.
Sandbox durations for testing subscriptions
After adding testers in Sandbox, you can choose a subscription renewal speed for each tester, allowing you to determine how quickly subscriptions renew. By default, the accounts are set to a speed equalization of 1 month = 5 minutes. However, you can adjust the renewal period speed based on the options below.
Subscriptions will automatically renew up to 12 times per account, but the actual number of renewals is random — in our practice, it’s up to 6.
|App Store Duration
In App Store Connect, you can select a subscription renewal rate for each Sandbox Apple ID account.
Test iOS subscriptions with Sandbox
To test whether you iOS subscriptions work properly, use testing device:
- Go to Settings > App Store > Log into Sandbox tester account.
- Initiate a purchase in your app.
- You might be asked to fill in your account details again. You might not expect this, but that’s normal.
- Wait for the alert from Apple about the successful purchase.
Test upgrades, downgrades, and crossgrades iOS subscriptions in Sandbox
To test upgrades, downgrades, and crossgrades of iOS subscriptions in the sandbox environment, you can follow the steps below:
- Subscribe to the monthly subscription within your app.
- Open the Settings app on your device and go to “App Store” under your Sandbox account.
- Tap “Manage” and then select “Subscriptions.”
- Choose your existing subscription and select a different product from the list of options to change your subscription. If you want to downgrade your subscription, you’ll need to wait 5-10 minutes before proceeding to the next step.
- Launch your app again.
- Verify that the user is subscribed to the new product and that the changes to the subscription have taken effect.
Test subscription cancellation on iOS
- On your iOS device, go to Settings > App Store.
- Under the Sandbox Account section, tap on your highlighted Sandbox Apple ID and select “Manage.”
- Choose the subscription product that you want to cancel from the Subscriptions page.
- Tap on the “Cancel Subscription” button.
- No active subscriptions could be found.
Reenable subscription renewal:
On the same “Manage Subscriptions” page, tap on the canceled subscription and confirm the payment to reenable the subscription renewal.
Test Restore Purchase on iOS
To test the functionality of restoring a purchase during an active subscription in the iOS sandbox environment, it is important to note that unlike the production sandbox and production environments, there is no receipt file generated on the device until a purchase is made. Therefore, to fully test restoring a purchase in the Sandbox, a button, gesture, or another method needs to be added to the app to revert it to the unsubscribed state.
Testing the restoration of a purchase during an active subscription in the sandbox environment involves the following steps:
- Sign up for a monthly subscription.
- Reinstall the app and make sure that you don’t have any subscriptions there.
- Use a button or gesture that was added to revert the app to the unsubscribed state.
- Tap the “Restore Purchases” button.
- If this is done before the subscription cycle ends (within 35 minutes), the app should detect an active subscription and change to the subscribed state.
To test the restoration of purchases across devices in the sandbox environment, follow these steps:
- Subscribe to a monthly plan on device A.
- Install the app on device B before the subscription expires.
- Log into the same Sandbox account used on device A.
- Launch the app on device B.
- Tap the “Restore Purchases” button.
Test billing issues on iOS
Once you have tested the entire process, you can implement your in-app purchases in your production app. It is important to note that you will need to use different settings and test user accounts in your production app than you used in the sandbox environment.
In summary, testing in-app purchases in the sandbox environment is a crucial step in ensuring that your app is functioning properly before submitting it to the App Store.
Qonversion is an all-in-one solution that provides developers with a cross-platform infrastructure for managing subscriptions and users’ access between iOS and web platforms. With Qonversion, you can ensure that your subscription model works seamlessly across all devices, minimizing the possibility of billing issues. It also provides a comprehensive analytics dashboard with valuable insights into user behavior and subscription performance.