80

I am working on adding In-App purchases to my app.

I am able to receive the productsRequest:didReceiveResponse method, and receive the array of products.

My problem arises when I add a SKPayment to the SKPaymentQueue. After I add the product to the queue, in the paymentQueue:updatedTransactions method the transactions always have the state SKPaymentTransactionStateFailed.

I NSLog the "transaction.error" and this is what it returns: Error Domain=SKErrorDomain Code=0 UserInfo=0x165000 "Cannot connect to iTunes Store"

I have logged out of the Store in the Settings app, but after trying to purchase a product in my app it never asks me to log in with my test account. It just fails with the above error.

4

26 Answers 26

50

I was getting SKPaymentTransactionStateFailed error code 0 "Cannot connect to iTunes Store" and thanks to thomax for this answer my problem is solved. Turns out you MUST enter a build number under Targets->Summary.

I spent the last 24 hours resetting my phone, screwing with iTunes connect, and doing just about everything i could think of before i stumbled upon this solution.

SKPaymentTransactionStateFailed code 0 Cannot connect to iTunes Store

SKPaymentTransactionStateFailed code 0 Cannot connect to iTunes Store

10
  • 38
    Seriously Apple? Cannot connect to iTunes Store is the error. How about... "Cannot connect to iTunes Store because you left the damn build field blank under your target summary"
    – AlBeebe
    Oct 27, 2012 at 11:46
  • 5
    Dammit! Had this same issue for three entire days! Thank you, kind savior!
    – scooterman
    Feb 6, 2013 at 20:20
  • @Guy Check this out too, might help... stackoverflow.com/questions/2138972/…
    – AlBeebe
    Mar 20, 2013 at 23:55
  • It works for me. But restoring will not works(. Build field is empty than restoring works perfect, but purchasing is not working.
    – Igor
    May 22, 2013 at 5:17
  • 2
    This solved it for me. Wish this post was higher up on the list; would have saved me a day or two and lots of headaches.
    – Mike
    Jun 17, 2013 at 14:54
25

I assume you've done the standard sanity checks: double-checking your code, confirming your product IDs, comparing your code to the In-App Purchase Programming Guide, etc.

This may be ridiculous, but -- if you're certain your code is correct -- do a hard reset (full wipe) of your iPod (Settings => General => Reset => Erase All Content and Settings). I puzzled over this exact problem for hours -- it turned out my code was correct and the hard reset was the solution.

9
  • 4
    I had this problem before and I did a full restore which didn't solve the issue. It turned out the Sandbox servers were down. So before following this advice I strongly suggest you check out the development forums for any known issues. Sep 15, 2010 at 11:30
  • 2
    @Daniel: is there a sandbox status link? Thanks!
    – Olie
    Mar 30, 2011 at 21:46
  • 13
    What I concern is that if we have to do a hard reset on our devices. Do others have to do the same way to purchase? Nobody want to do a hard reset just to buy one in-app purchase..
    – Chanok
    Jun 2, 2011 at 4:55
  • 13
    it is amazing how Apple never resolved this issue, since iOS 3.
    – Duck
    Jul 29, 2012 at 18:33
  • 2
    There's a post below that explains YOU MUST HAVE A BUILD NUMBER! Only having a Version # is not sufficient. I don't know why this is, but it is. If you're wondering why I didn't have a build number, it's because we have separate processes to add the build number in when we create a testing or production build.
    – Mike
    Jun 17, 2013 at 14:55
21

I had been getting the same error but I had been prompted for my test user account. And also a popup saying "An unknown error has occurred". It turns out that when I created my test user account and signed out of the settings -> store I had decided to sign in with my test user account which had prompted me for a bunch of information including billing, which had broken my test user account. When I created a new test user account and only signed in when prompted to during the in app purchase testing, everything worked smoothly.

2
  • 1
    Gah, that was my problem too. If you put card details in anywhere you've gone wrong. Mar 19, 2013 at 15:03
  • Same issue for me too! Nov 14, 2014 at 17:32
17

This error (i.e. "Error! Cannot connect to iTunes Store") can occur if you do a sandboxed In App purchase but are signed in using your normal Apple account.

I find it helps avoid any confusion if I sign out of my Apple account before doing any In App purchases. Then in the "Sign In" dialog choose the "Use Existing Apple ID" option and enter your Test User details.

Just remember this will be set in your Settings so you will need to sign out after you've finished In App purchases.

Also, using a different Apple ID resets various iTunes-related settings such as iTunes Match.

14

You can check if the following link is working or timing out:

https://sandbox.itunes.apple.com/verifyReceipt

Alternatively, an unscientific but quite reliable way to check if the sandbox is working is to ask at:

https://devforums.apple.com/community/ios/connected/purchase

If the sandbox is down, there will probably be people already talking about it, like now (18 Jan 2012, 6:40pm UTC time).

1
  • 1
    The Devforums link you supplied shows: "The item does not exist. It may have been deleted."
    – Guy
    Mar 20, 2013 at 21:00
7

I also was facing with the same error. I figured out, that the Error only comes on the Simulator, when I switched to the device debugging, the error didn't appear.

1
  • 1
    Switching to the device worked for me, may or may not be important to note I was careful to logout of my own personal iTunes account first after reading other comments here. Then logging in with the test account when prompted.
    – nacross
    Oct 16, 2014 at 11:30
5

Simply log off from your AppStore account on settings...

Solved the problem for me because my device was logged using my regular Apple ID and because the purchases on the sandbox are always done with the test user ID, the device was trying to send my regular Apple Store ID to the "test" App Store resulting on this "Cannot Connect to iTunes Store" error.

This is the most common cause I have seen on my device.

3
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
    – CSchulz
    Feb 22, 2014 at 14:36
  • yes, it does. Logging off from the App Store solved the error "cannot connect to iTunes Store" for me. Next time you have this problem try this.
    – Duck
    Feb 22, 2014 at 14:56
  • At the timepoint when I reviewed your answer there was only one sentence "Simply log off from your AppStore account on settings...". It was marked as low quality. I am sorry.
    – CSchulz
    Feb 22, 2014 at 15:39
4

Hit with the same problem, i reset my device, cross verified the identifiers, re-installed the app. Also thought the problem was, because I had changed the reference and the description of the products. In reality, I feel it is because my test user had got locked as multiple people where using the same account, and it is a possibility that the password validation failed multiple times. So I re-created another test user and in-app purchasing is back to working. Hope this helps. I was totally stumped with this error.

1
  • Creating another test user worked for me as well. I think resetting the device works for error code -1003, but a new user account works for error code 0. Nov 11, 2011 at 21:55
4

Make sure your BundleIDs match. That was my problem.

1
  • that one saved me! had a mismatched bundle id. Thanks!
    – Lukas
    Apr 18, 2012 at 9:53
4

Even a full restore did not resolve this problem for me.

After calling addPayment for an auto-renewing product identifier, about one second passed before I received the "SKErrorDomain Code=0" error from StoreKit. At no point was I prompted (as Apple's documentation suggests one should be) for an iTunes Store username and password; the transaction simply failed.

To resolve this, I had to add a fake "consumable" product to iTunes Connect and call addPayment using the fake consumable's product identifier. This caused the iTunes Store dialog to come up. I then logged in with a test account I had created in iTunes Connect. This succeeded: my application was notified that the consumable had been purchased.

After having done this, I was able to call addPayment with my auto-renewing product identifier and purchase the subscription normally.

4

make sure you're testing with sandbox user accounts created from itunesconnect and not your actual apple id for your personal account when testing this stuff.

3

I thought it worth mentioning that DonnaLea's solution of only logging in when prompted for payment also worked for the same issue with Unity and Prime31's StoreKit plugin. Attempting to log in via the same settings menu you use to log out will prompt for all manner of billing\address details which seems to permanently "break" that test account.

1

I found myself in this situation when I was working on adding in-app purchases and didn't do it exactly right the first time. In my case I had an error in server-side PHP and as a result I think I wasn't getting all the way through to "finishTransaction:". Even after I fixed the problems (I put the program on a separate device and purchased successfully), I kept getting "You've already purchased this, click to download" followed by "Cannot connect to iTunes Store".

I finally got it to stop doing that by launching the game from Springboard (not XCode). It immediately processed the transaction successfully and stopped prompting me to redownload.

1

This is similar to the accepted answer above. I started getting the "cannot connect to iTunes store" error when trying to log in to my iTunes account on my phone after logging in with an IAP sandbox account.

To solve the problem, I was able to just do a Reset All Settings instead of Erase All Content and Settings (Settings => General => Reset => Reset All Settings). Definitely better than having to lose and reinstall everything on your device.

1

I had had the same problem, first of all I haven't created test account so I created via getting help from this link https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SettingUpUserAccounts.html#//apple_ref/doc/uid/TP40011225-CH25-SW10

Then You need to sign out from your current account on your device. and buy purchasing it will ask for user account, then enter the test account.

0

I had this same issue. I had previously created a test user account, and signed out of the itunes store expecting to be prompted with a sign in for my test user account when I made the in app purchase. instead I got the cannot connect to itunes store message. when I signed in with my real itunes username/password and tried my test app it worked perfectly. I then logged out of itunes store again and my app worked great, prompting me for my id/pw

0
0

I had the same error, but the problem was not exactly the same. Maybe usefull for someone:

I inserted an external file in the structure of my app. The reason why I did this is because in production, I insert this file dinamicaly from a server, but in development I thought it was faster to use an app called iExplorer to paste this file. I have done this is the past and I didn't have this problem. But in the last few days, if I paste this file directly using iExplorer, my app returns the error: "Cannot connect to iTunes Store". (in spanish: "No puede conectarse a iTunes Store").

I think that it is because this time I inserted the file inside the .app folder. So this makes me think that if you modify your .app folder in any way, the Codesignature breaks and the link with the iTunes Store stops working directly.

0

For me, the problem was fixed by uploading a binary. Since that answer was not given in this page, which seems to be among the top hits in Google, I thought I'd add it.

0

Figured I should share my recent experience with the same issue:

I experienced the same problem a few days ago, where it stopped working from one day to the other. I got the following error after having authenticated with my test user(s): Error Domain=SKErrorDomain Code=0 UserInfo=0x165000 "Cannot connect to iTunes Store"

I hadn't done any changes to the code and we couldn't think of any other changes to our iTunes account or IAP products that might've triggered the problems. The only thing that may have been related was the adding of more iTunes Test Users (although I've added ~15 accounts before without problems). I tested it on different devices and the simulator.

I went through all the available checklists and all possible solutions (everything mentioned above as well) without any success. Finally I figured I might as well take a break from it all over the weekend, since I was drawing blanks. And oddly (and for the first time ever), doing nothing actually worked! I didn't change any code, nor did anything change on our iTunes account or the app.

The only reasons I can think of are:

  1. Something was wrong on Apple's end.
  2. Some other time-based factor with the app, a certificate or something caused the problems.
  3. A leprechaun snuck into my office and fixed the issue.
0

Check if you are signed into your personal itunes account in the appstore. If you are you will receive this message. Even if you are signed into your sandbox account in the app. So, to resolve this issue sign out of your personal account in the app store and then try to purchase your in-app item and then use your sandbox account. This resolved my issue.

0

Well, as usual I "tried all solutions available and it didn't help" :) So, here is my input to this unlimited collection of stumble stones:

If application is not currently on sale (at any reason), this error occurs.

0

I got the same error, When I called SKProductsRequest's start method in my test env, It ran in - (void)request:(SKRequest *)request didFailWithError:(NSError *)error

When I called in my production env, It's correct and ran in - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response

Close charles or any http proxy software asap! Close charles or any http proxy software asap! Close charles or any http proxy software asap!

You know it~

0

I had had the same problem, but I solved by the following mode:
- I was using iPhone 5S emulator with iOS 8.4 (This is the most important. Apple Store connection is not working on iOS 11 emulator)
- on emulator I turned on the following setting: Settings/Developer/Allow HTTP services (This is for internet connection)
- temporarily I turned off Avast antivirus Web Shield (This is for internet connection too)

0

The In-App Purchase FAQ has this information:

Cannot connect to iTunes Store

The "Cannot connect to iTunes Store" issue may be due to one or more of the following reasons:

  • The sandbox may be unreachable.
  • Your app does not have a bundle version (CFBundleVersion). See Setting the Version Number and Build String for more information.
  • Your app is running in the Simulator, which does not support in-app purchase.
  • You are attempting to purchase a product that is unavailable for sale. See Query the App Store for product information before presenting your app’s store UI for more information.

In my case, the error occurred because I was using the simulator.

Even in the In-App Purchase Programming Guide says to use the development iOS device has a suggested testing step.

0

As Apple's Documentation:

Cannot connect to iTunes Store The "Cannot connect to iTunes Store" issue may be due to one or more of the following reasons:

  1. The sandbox may be unreachable.
  2. Your app does not have a bundle version (CFBundleVersion). See Setting the Version Number and Build String for more information.
  3. Your app is running in the Simulator, which does not support in-app purchase.
  4. You are attempting to purchase a product that is unavailable for sale. See Query the App Store for product information before presenting your app’s store UI for more information.

https://developer.apple.com/library/content/technotes/tn2413/_index.html

1
  • Some others: change build version to largest version, logout current account in setting of devices. Now run app again Mar 21, 2018 at 11:12
0

I have tried all what I can to deal with this issue.

Real device not Simulator.

New registered Sandbox test account (not fill the extra info to make it a formal Apple ID)

Logout whatever accounts related.(iCould, App Store, maybe other app's sandbox testing account)

Fill all the tax and Agreements in itunesconnect website

Even restore to factory settings LOL ...

always return SKErrorDomain Code=0

“Cannot connect to iTunes Store”

...

My case's solution is finally come tome after 3 days' struggle:

And finally I find the key. Try with another device to test the iAP if your device's iOS is iOS13.4.x!!!And I upgrade this ”broken“ device's OS version to iOS14.0.1, iAP works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.