Configure sandbox testing
Configuring your IOS app to enable sandbox testing can be sometimes a daunting task.
But no worry, we listed below all the steps required to make it work!
Apple Developer Program
You must be enrolled in the Apple Developer Program.
If you're already enrolled make sure your subscription isn't expired (it must be renewed every year).
Check your agreements
Make sure to sign the Paid Applications Agreement and set up your banking and tax.
If the agreement hasn't been signed correctly, you'll get an empty array when fetching your in-app products.
Apple can take hours to days to approve these IAP-related agreements after you submit them.
Create a sandbox user
On the App Store Connect, click on User and Access in the menu next to the logo.
On the left menu, click on Testers in the sandbox section.
Click on the + button to create a sandbox user.
The email address you enter should NOT already be associated with an Apple ID account.
You can use an email alias instead of having to create a brand new account.
Add sandbox account to your testing device
Starting IOS 12 there is finally a way to use a sandbox account without signing out of your Itunes account.
Go to Settings > iTunes & App Store, scroll down to the end of the page and you'll find a Sandbox account section where you'll be able to log in to your sandbox account.
The sandbox account will only be used while developing locally, your existing app Store account will be used for TestFlight apps.
Project configuration
It is important you check that the bundle identifier of your app match the one you've created on the Developer Center and on the App Store Connect.
The In-App purchases capability must be enabled as well in the configuration of your project.
If the In-App purchases capability doesn't show up in the list, make sure you're logged in with the correct Apple ID on Xcode.
Finally
When sandbox testing is configured correctly, you should be able to load and purchase the products.
You should see as well [Environment: Sandbox] when confirming your purchase.
For more informations, please go to the official Apple documentation: In-App Purchase