How does one properly test within the sandbox for apple in-app purchases?

1k views Asked by At

I have a brand new app, has not been published yet. I added an in-app purchase to the code, went through the process of adding the product to the app in "app store connect", and added a sandbox user there as well.

To test, I plug in my phone to the mac, and from xcode (13.3.1) I run the app on my phone. The app runs, and I see the product show up in the app. When I hit the button to "buy", I immediately get a dialog to enter credentials. I enter the sandbox credentials, then get another alert saying "Apple ID verification, open settings to continue signing in with.."

I do that, then it pops up a 2-factor dialog saying a code has been sent, but the dialog just goes away after the code is sent via sms to that same device. There's no place to enter that code, as if it knew "oh, the code is being sent to the device that wants it". After a couple of seconds, I end up in Settings->App store, and I don't see anything useful there.

I then go back to the app, and w/o doing anything in the app I immediately get messages in the debug console:

Payment Queue Error: Optional(Error Domain=SKErrorDomain Code=0 "An unknown error occurred" UserInfo={NSLocalizedDescription=An unknown error occurred, NSUnderlyingError=0x28160ee80 {Error Domain=ASDErrorDomain Code=500 "Unhandled exception" UserInfo={NSUnderlyingError=0x2816dc150 {Error Domain=AMSErrorDomain Code=100 "Authentication Failed" UserInfo={NSMultipleUnderlyingErrorsKey=(
    "Error Domain=AMSErrorDomain Code=2 \"An unknown error occurred. Please try again.\" UserInfo={NSLocalizedDescription=An unknown error occurred. Please try again.}",
    "Error Domain=AMSServerErrorDomain Code=-5000 \"(null)\" UserInfo={failureType=-5000, m-allowed=false, pings=(\n), cancel-purchase-batch=true, customerMessage=The Apple\U00a0ID you entered couldn\U2019t be found or your password was incorrect. Please try again.}"
), NSLocalizedDescription=Authentication Failed, NSLocalizedFailureReason=The authentication failed.}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception}}})

I know the account credentials are correct (tried several times and verified them). It's almost as if I'm not really hitting the "sandbox" user db, more like production. But everything I read says I should be in development mode when I run things like this (based on What is a "development-signed version" of an iOS app? How do I run a development-signed version of my app?)

Is there some more precise way of determining whether or not I'm in development mode? Maybe some setting got tweaked or something.

1

There are 1 answers

0
Jack On BEST ANSWER

Sorry, my bad. I had created the test account in the "regular user" section, not the "sandbox user" section up at "App store connect" (that's why I was getting the auth errors).

Things work fine with a real sandbox tester account.