I had the same problem (with Storekit 1 though. Not sure if that makes a difference). As long as you have your StoreKit file in your project it will always use this method. If you want to switch to Sandbox testing with the In App purchases (already set up in app store connect) from the app store just remove the StoreKit file from your project and also do not forget to remove it from Run configuration "Edit Scheme" where you added you Storekit before.
From now on you should be presented with the same modal but the title should say "Sandbox" instead of "Xcode".
Post
Replies
Boosts
Views
Activity
Have exactly the same problem. App works with StoreKit fine, but as soon as I remove StoreKit file and want to testing sandbox version it brings up the payment modal again and again... Also I have the inApp purchases configured in AppStore Connect and all of the details of the inApp purchase (like name, details, price) show up normal, but as soon as I hit buy, i get a confirmation sound but the transaction stays in progress and the buy modal pops up again after 4-5 seconds.
Is this maybe related, that the inApp purchase is currently "in review", or "submitted for review" (I am not able to release the IAP because I need to submit a new app version with that too). I also searched a lot but did not find a solution to that, but at least we have the exactly same issue.
As already answered in a different similar thread. This seems to be just a simulator issue. If tested on REAL devices the sandbox payment worked flawlessly. So make sure not to just rely on the simulator on this.