You are not authorized to make purchases of this InApp in Sandbox at this time
You can use In-App purchase test users, to test In-App purchase in sandbox mode.
Create test users in the "Users and Access" section of appstoreconnect.apple.com
Before testing In-App purchase, Using the Settings app, logout your actual Apple ID and login the test user account directly via your app. (DON'T login the test user via Settings app or AppStore.)
They used to have the real iTunes login and the Sandbox iTunes login grouped back in 2017. So you would sign in to your Sandbox account while testing purchases in the app, and then it would change your iTunes login as well. Then you'd have to sign out of your iTunes through settings. Now they have a separate field on the bottom of the Settings --> Itunes & App Stores screen (called "Sandbox Account"). You have to sign in there with a provisioned Sandbox account which is added in "Users & Access" in App Store Connect. (You have to also verify that email address, and it can not use a +postfix on the email address, IF that email is used as one of your non-sandbox main accounts... Sigh...) So you have to actually create new unique emails now that are not used as part of your main accounts. (From my understanding you can still use +postfixes on your emails which are only used for sandbox accounts though :)
Now, there's still a bug with purchases where If you are not signed in with your main Itunes account, OR your sandbox account, and you try to test purchases by typing in a sandbox account (in the app), it will keep asking you for your Sandbox Email / Password over and over again, Until you type in your REAL iTunes account as well (????). That works (typing in both the sandbox account and the real itunes account). Then the sandbox purchase goes through. I'm as surprised as you are...