Sandbox iAP not working

Hi there,


I've run into the following problem: when attempting to make a test purchase in our new game, I get the following error: "Unable to purchase: Cannot connect to iTunes Store"


The precise error we're getting is:


Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store"


Now, all the iAP objects are being received correctly by the productsRequest in the delegate, but on every device we've tried (iPad Air w/iOS 9.01, iPad 4 w/iOS 8, iPhone 6+ w/iOS 9.1, and a few others) we get the same issue when attempting to make an actual purchase.


This whether we build it with Xcode 7 stable or the latest beta (for our 9.1 device).


I have confirmed that our provisioning profile is for the correct bundle ID and that we're using the correct sandbox user created in iTunes Connect.


Googling the issue, I've found a few references to it being Apple's sandbox environment that is down, but I've got no way to confirm this and haven't seen anyone else complaining about the same issue.


Any suggestions?


Thanks,


Rohan

Answered by PBK in 74321022

One reason for getting this error is that your app is directing itself to the production website not the sandbox website and it suddenly realizes its not supposed to do that. So please confirm that you

- DELETED old builds of the app from your device and

- logged out of the app store before

- reinstalling your app on a device (not the simulator)

- from Xcode.

Oh - the precise transaction state I get back is:


SKPaymentTransactionStateFailed, // Transaction was cancelled or failed before being added to the server queue.


And it happens immediately, with little enough delay that I'm now fairly sure nothing is being sent off and it's probably not some kind of sandbox issue as people suggest.

FYI - I have tested this on our older app using the same codebase, one that is live on the store.


We get the same results whichever sandbox account we use - the same error, using a sandbox OR live account.


(The live build on the store works perfectly.)


I've traced over our iAP code in our debug build and it all seems to be working fine, with all the purchases for both programs populating correctly, but the same error,


Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store"


...appears every time you attempt to make a purchase.


I'm at a loose end here. We had a deadline to submit an app yesterday, but I've got no idea if this will simply go away in the time it's waiting for review, or if there is indeed a code error at our own somehow.


Rohan

Accepted Answer

One reason for getting this error is that your app is directing itself to the production website not the sandbox website and it suddenly realizes its not supposed to do that. So please confirm that you

- DELETED old builds of the app from your device and

- logged out of the app store before

- reinstalling your app on a device (not the simulator)

- from Xcode.

Thanks very much, PBK!


I had performed all the deleting, etc, but I tried manually creating a development profile instead of letting Xcode do it.


This, combined with fully logging out of the App Store (something I never had to do with iOS 8) solved the problem.


I will check to see if the manual provisioning profile is required, but either way, it's working now.

Sandbox iAP not working
 
 
Q