How to test IAP in the Sandbox environment?

I've been reading through the documents and I feel like each particular doc jumps over the piece of info that I need. It explains how to create a Sandbox Test User and I've done that. I did plenty of IAP work many years ago, but things have changed enough that it's not working as I expect. When I read the docs, I feel like I can't find the missing piece.

When I test in a simulator with Xcode, it does my IAP transactions in the Xcode environment. That makes sense.

https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox

This page says:

To run your app using your Sandbox Apple ID, build and run your app from Xcode.

But when I test on a physical device installing directly from Xcode, it also does my IAP transactions in the Xcode environment. I thought this would put me in the Sandbox environment, but it didn't. The initial purchase view controller didn't reference the Sandbox at all and the "You're All Set" alert shows Environment: Xcode.

When I put a test build into TestFlight and test using that version, my IAP transactions are happening in production using my real Apple Id (but I'm not actually charged for any transactions).

I assumed that testing in TestFlight would give me the Sandbox environment, but it happens in the Production environment. (The purchase view controller doesn't show Sandbox and the "You're All Set" alert doesn't show Sandbox.)

So, how do I test in the Sandbox? Every way I try to test either puts me in the Xcode environment or the Production Environment.

What am I missing?

I've logged out of my real Apple id on my phone and then logged in with the Sandbox User credentials I created in AppStore Connect. But when I tried to test the app, by installing from Xcode it still says I'm in the Xcode test environment. When I create transactions, those transactions show up in the Xcode Transaction Manager.

How do I test in the Sandbox environment?

I'm having the exact same issue. The documentation says, "Your development-signed app uses the sandbox environment when you sign in to the App Store using a Sandbox Apple ID". Two requisite conditions: a development-signed app and being signed in with a sandbox apple id. Sounds simple but there must be something missing because I can't seem to end up in any scenario besides XCode test env or production either.

Same issue here

same issue here

I am seeing this issue as well.

You need to make sure there is no storekit configration used in your scheme, otherwise the xcode env will be applied.

this saved me lot of time, thank you!

How to test IAP in the Sandbox environment?
 
 
Q