Sandbox IAP Alternates Between Success and [ Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" ]

I have been implementing IAP in my app, and have been trying to test purchases over the last few days. I have tried from scratch following Apple's guidelines, and online tutorials, all the way to using Swifty Storekit and IAPManager.


Here's what happens: I press buy for my consumeable IAP, then there is a sucessful purchase. If I try to buy it again, there failed purchase with the following error:


Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" 
UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}


If I buy it a third time, it works fine. And so on in that pattern.


Observations/testing:

  • Pattern follows between launches
  • Pattern follows across devices
  • Reproduceable in iOS9 & iOS10
  • Using xcode8 and swift3
  • Deleted my previous sandbox testers and created a new one and problem persists
  • Tried vasious waits between purchases, up to 10 minutes, problem persists.


Any ideas on what could cause this? I am suspecting when live it will be fine, but it is really realy odd.

Accepted Reply

After numerous reports of this issue to DTS, I managed to replicate the problem myself. So far as I can tell, the issue occurs only with new test user accounts. If you go to your iTunesConnect account and enter "User and Roles" -> "Sandbox Testers" page, you will see a list of your sandbox test accounts. If you create a new test user account, notice that there is a check mark in the rightmost column, "Apple Pay". Using such a test account appears to trigger this problem. Developers who have older test user accounts (defined prior to June 13. 2016) won't see this problem.


I've submitted a bug report on this matter, but what I need is a TestFlight submission along with a developer test user account. I think I have such a build coming and will forward the issue to iTunes Production Support for investigation by tomorrow. My suspicion is that this will not affect application submissions - App Reivew tests with mostly established production accounts. This problem will get a lot more (and quicker attention) if it happens in the production environment.


I'll see if I can update this posting when I learn that the problem is fixed.


rich kubota - rkubota@apple.com

developer technical support CoreOS/Hardware/MFI

Replies

Is this still a problem? It was for me yesterday, Thursday 10/26/16 and this morning, Friday 10/27/16 it's the same issue.

Still happening to me too. Started yesterday, October 26, and still not working yet today.

Magically started working for me today (didn't check since Monday, 2017-10-30, though). Of course there were no code changes, so it was definitely on Apple's side. Let's see how long it will work 😁