You can test your In App Purchases and S2S transaction from the Sandbox environment, without creating financial transactions, or processing actual payments. It returns transactions as if payments were processed successfully.
The Apple Sandbox environment lets you test your In App Purchases using the StoreKit framework which makes use of real product information from App Store Connect.
⚠️ You can test only with an application that is setup on Apple App Store Connect with TestFlight
Steps to follow the test are as follows:
How to create a Sandbox Apple ID or Test account
Create Sandbox tester account in the App Store Connect in Users and Access-> Testers under Sandbox-> Click on + icon -> Enter Tester information (like name, email, password, etc..) -> Click invite.
In App Store Connect to test development signed version of your app to test In-App Purchases or Apple Pay: https://help.apple.com/app-store-connect/#/dev8b997bee1
Sign in to the App Store with Sandbox Apple ID
Build and run your app from Xcode in order to run your app using your Sandbox Apple ID.
In iOS and iPadOS, the Sandbox account is in Settings > App Store once you use the device make a purchase in a development-signed app. You need not sign out of the non-Sandbox Apple ID account.
In macOS, the Sandbox account is in App Store > Preferences once you make a purchase. You need to sign out of the Sandbox Apple ID after testing.
If your test device has macOS 11.1 or earlier installed, sign out of the Mac App Store, then build your app in Xcode and launch it from Finder.
[Environment: Sandbox]appears, indicating that you are connected to the test environment.
You should be running a development-signed build of your app; production-signed builds use the production environment.
Test In-App purchase
In-app products created in App Store Connect are available for sale in all App Store regions.
To test In-App Purchases in multiple regions using the same Sandbox Apple ID, open App Store Connect, click on the Sandbox Apple ID, and change the App Store Country or Region setting.
App Store Country or Region
Change the account region to any of the 175 different regions recognised by the App Store, on different storefronts using the same Sandbox Apple ID, without having to create new testers.
Subscription Renewal Rate
You can choose a subscription renewal rate for each tester to speed up or slow down how often subscriptions renew.
Subscriptions are automatically canceled after 12 renewals.
By default, a one-month renewal lasts five minutes. If you wish to speed up the renewal period, you can choose three minutes.
If you wish to slow down the renewal period, you can choose 15 minutes, 30 minutes, or an hour.
To activate a storefront after changing the region in App Store Connect, sign out of the Sandbox Apple ID account and sign back in.
Changing the App Store Country or Region setting affects the storefront value in your app.
You can test interrupted purchase scenarios on a device running iOS 14 by enabling interrupted purchases in App Store Connect for a specific tester ID.
When it is selected the Apple ID will be interrupted in the sandbox environment and continue to be interrupted until the option is deselected or the tester agrees to the terms and conditions on their iOS device or until resolved.
All purchases will be interrupted for that Sandbox Apple ID, preventing the transaction from completing until resolved.
This allows you to test your app’s handling of an interruption to ensure a seamless customer experience.
In general, an interrupted purchase is experienced anytime a customer needs to address an issue with their Apple ID as if they need to agree to updated terms and conditions or they need to update an expired payment method.
Clear the Purchase history
To manage repeated testing with the same Sandbox Apple ID, clear its purchase history in App Store Connect.
Clearing the purchase history with a high number of purchases may take a longer time.
When the process is complete, the transaction history and receipt are empty and the Sandbox Apple ID will be eligible for introductory offers.
The tester with the Sandbox Apple ID can purchase subscriptions they were previously subscribed to without causing a duplicate purchase.
Clearing the purchase history doesn’t affect In-App Purchases that customers make on the App Store.