100

I am having problems testing my in-app purchases. I get back valid product identifiers, but upon purchase I receive the dreaded "Cannot connect to iTunes Store". Interesting thing is that restore purchases seems to work - iTunes login pops up.

I have: - Checked that my in-app purchases are cleared for sale - Checked, rechecked my source code to be in sync with Apple's documentation - Added appropiate test users - app id does not contain wildcard - in-app purchases are linked to the app (app itself is in developer rejected state, purchases are in ready to submit) - waited - reinstalled app, cleaned solution, all the voodoo stuff

James Webster
  • 30,976
  • 11
  • 64
  • 113
arkir
  • 992
  • 2
  • 6
  • 6

17 Answers17

114

Make sure you have signed out of any production iTunes accounts on the device.

I was getting this error on my test phone which was logged in with my actual iTunes account. You cannot test apps using your production iTunes account, hence the error. I just wish Apple provided a better error so as to avoid this guesswork...

stevel
  • 1,585
  • 1
  • 13
  • 13
  • 1
    My error was simply not setting up a Sandbox User, I forgot that step. And don't log into it from the Settings >> iTunes section of the device b/c that will break it. Wait and do it during the actual testing. – Nathan Prather Jul 22 '16 at 03:12
  • You may also be getting this error when reusing an old sandbox account you tested a previous IAP on another app with (My scenario). Apple really needs to update the way we test IAPs, I'm running out of emails :0 – David Baez Jan 23 '18 at 01:38
  • I am testing it in the simulator, so this shouldn't be the problem here right? – Usama bin Attique May 22 '18 at 09:11
  • 2
    logged out from all iTunes accounts. its prompt me for sign-In required and then transection gets failed. used many sandbox tester account but won't work. – bLacK hoLE Oct 04 '18 at 12:02
  • For me this doesn't work either... Tried creating many accounts, some with logged in iTunes sandbox user, others without logged in user, even without confirming e-mail, nothing works! – Borzh Oct 06 '18 at 23:58
  • Tried this but did not work, I had to go make sure my In Apps were ready for submission then came back to try on the app then it worked – cherucole Apr 03 '20 at 17:27
  • @stevel ! Why can't I test with my actual account ? I mean at some point I need to test with actual account as well. – Waqas Jul 20 '20 at 07:59
50

see In-App Purchase FAQ: Cannot connect to iTunes Store

Your app is running in the Simulator, which does not support In-App Purchase

For testing in app purchases always use real devices.

Saqib Omer
  • 4,917
  • 7
  • 46
  • 65
DShah
  • 9,510
  • 10
  • 66
  • 123
26

For newcomers, make sure your in-app purchasing product's status is Ready to Submit, with no "missing metadata". In my case, what was missing was the localization of the subscription's group.

enter image description here

Dielson Sales
  • 1,586
  • 1
  • 21
  • 23
10

I've been having this problem and I'm convinced its a bug. I've filed a bug report with Bug Id 10108270

The problem seems to be that the test user is getting 'locked' and may have something to do with attempting to purchase an in app purchase in an already released app with that account.

My workaround was to create a new test user but until Apple get back to me, I can't provide any better solutions. I'll update this answer when I get replies.

James Webster
  • 30,976
  • 11
  • 64
  • 113
  • 4
    I have created a new test user, but it didn't help. – arkir Sep 13 '11 at 13:55
  • I'm sorry I can't help more, that was my workaround, it's a shame it doesn't work for you. I'll keep this answer updated when I get more information. – James Webster Sep 13 '11 at 14:13
  • I created a new test account and in-app purchase started working again. Thanks! – Miha Hribar Sep 27 '11 at 13:28
  • Creating a new test user solved the problem for me. (A few days ago I got a notice when trying to use my old test user that it had been disabled, so I had to go re-enable it. Soon after that, I started getting the `Cannot connect to iTunes store` error. But once I created a new test user, purchases worked again.) – Andrew Nov 11 '11 at 05:25
  • new user worked for me. just try before doing anything else. – Okhan Okbay Jul 28 '20 at 20:03
7

This problem remains persistent in 2016. Incredible. Here was my solution:

Add a build number. Target > General > Identities > Build.

  • 2
    UNBELIEVABLE. This is still an issue in 2018. I don't use a build number in debug mode because I increment it for production releases only. Thanks for posting this. – Steven Peterson Aug 04 '18 at 03:10
3

This is an old thread that is related to problem I was facing today.

In my case, I was able to test in-app purchases on my device till yesterday but it stopped working today. It turned out that Apple had pushed an 'Amendment for Paid Applications' for me to review and agree to. Once I agreed to the amendment (without reading it, of course), everything started working again. Did not have to create a new test user or any other workaround.

There may be many reasons for in-app purchases to not work but make sure you are correctly set up on itunesconnect or you won't be able to test in-app purchases.

Robert
  • 5,191
  • 43
  • 59
  • 113
PicSonics
  • 61
  • 6
2

Make sure the system status is ready https://www.apple.com/support/systemstatus/

I have an Iphone, Restart it worked for me

hguzman
  • 191
  • 4
  • 11
2

I'm hitting the same issue. For me it happens after this secuence:

  • Install app on a device logged into a UK account on iTunes
  • Launch the app and use a test user set in USA
  • Message is shown saying account is only valid in USA. Closes the app and auto launches iTunes
  • Open your app again and retry purchase. Receive products but no other callback or error.

I don't know whether this is an issue on the IAP platform but I would like to get an error/callback to handle it in some way in my code.

To carry on testing your IAPs try any of these:

  1. Remove Provisioning Profile in Settings area, remove App and log out from Store in Settings. Then go to XCode and change the signing identities to "Do Not Sign" to then put them back (I know how it sounds :) but try) OR
  2. Hard reset all Settings on your device (Settings -> General...). Obviously you will loose any settings on that device...
  3. Kill iTunes app on the device (multitask menu) and log out from the Store on the Settings

If none of the above work, it might be an issue on IAP platform, see my comments below.

Juan Fran Jimenez
  • 1,411
  • 14
  • 19
  • Thanks, but neither method 1 or 2 worked for me. Still cannot connect to iTunes. :( – arkir Sep 13 '11 at 16:53
  • Actually, I've tried myself and I can't either! I have a feeling this is a problem TODAY/RECENT with the platform. But I can't find any link to confirm it (status). Argh!. I'm leaving it for a few hours and see if that is the case and it's something external to the devs – Juan Fran Jimenez Sep 13 '11 at 17:12
  • Have tried to kill iTunes app on the device (multitask menu) and log out from the Store on the Settings? – Juan Fran Jimenez Sep 15 '11 at 10:01
  • Let me add that Game Center (sandbox at least) has been unstable for the last 5 days or so. Only last night started to work better. I'm mentioning it because my IAP code hasn't changed since my answer and now it works. I'm inclined to think there was an error on Apple IAP platform and that somehow was related to Game Center too. – Juan Fran Jimenez Sep 15 '11 at 10:17
1

You may also be getting this error when reusing an old sandbox account you tested a previous IAP on another app with (My scenario). Apple really needs to update the way we test IAPs, I'm running out of emails :0

David Baez
  • 1,068
  • 1
  • 11
  • 24
  • I had this issue as well. Sometimes creating a new user helps. Also you don't need to use a real email. I through -## at the end of mine and keep adding new ones. – Jeremiah Mar 24 '18 at 15:38
1

I was able to purchase in-app on iPhone but not on iPad(11.0.2). I tried with all mentioned solution but none helps. After trying all other possibilities, finally I was able to make it work.

When you create a test account in iTunes connect, don't verify the email id. If it is verified, iap returns "Cannot connect to iTunes" error. It looks strange but it is how worked for me. In iPhone, irrespective of email verification, I am able to purchase using test account.

Anish
  • 2,859
  • 1
  • 18
  • 40
  • 1
    I read this and it sounded crazy at first but it actually worked. Had exactly the same issue with test account not able to make purchase on iPad but working fine on iPhone. Very strange! – axanpi Mar 28 '19 at 02:53
  • 1
    Yes. This is weird. Our app got rejected due to this issue and i had to explain to apple review team with the reason and got it approved. – Anish Mar 28 '19 at 07:52
1

Here the exhaustive checklist if you got this error "cannot connect to iTunes Store" :

  • Make sure you have a sandbox user created in App Store Connect

  • Simulator DOES NOT support In-app purchase : test on real-device

  • The sandbox may be unreachable. Check the Apple System Status
  • Check that your app does have a bundle version (CFBundleVersion)
  • Check that the product is available for sale. Did you create it in App Store Connect?

  • If previous iOS 12, signed out of any production iTunes accounts on the device. Otherwise, you can just sign in within the dev app with your sandbox account.

Medhi
  • 798
  • 5
  • 8
0

This error also had occurred when to SKProductsRequest passed wrong NSSet:

Wrong:

let products = NSSet(objects: ["id1", "id2"])

Correct:

let products = NSSet(objects: "id1", "id2")
Igor
  • 11,227
  • 4
  • 49
  • 69
0

In my case, I just forgot to handle .failed in transactionState. In particular, SKPaymentQueueue.default().finishTransaction(transaction).

1nd3e
  • 73
  • 6
0

The same issue got for me, and I had checked on the issue including Apple form, I couldn't find a solution.

Today when I checking the device I found that the following

In Device Settings -> iTunes & App Store found another Apple Id logged In. So I tried signOut that and checked again the InApp purchase, it worked perfectly. So please check the issue is linked to the same or not.

Thanks & Regards, Unnikrishnan.P

Unnikrishnan
  • 118
  • 7
0

In addition to all the other methods outlined here, if you are working with subscriptions it seems you need to make sure you've generated a shared secret:

"To test or offer auto-renewable subscriptions, you must have a master shared secret or use an app-specific shared secret for each app."

A master shared secret is generated from the 'Shared Secret' tab of the 'Users and Access' section of App Store Connect.

An app-specific shared secret is generated where you manage the in-app purchases of the app itself.

Newtz
  • 1,303
  • 11
  • 9
0

I fixed mine! If you are getting Error Domain=SKErrorDomain Code=2 "Cannot connect to iTunes Store" error, make sure you insert SKPaymentQueue.default().finishTransaction(transaction). It worked for me after I added SKPaymentQueue.default().finishTransaction(trans) in the following:

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    for trans in transactions{
        if trans.transactionState == .purchased {
            print("Successful.")
            SKPaymentQueue.default().finishTransaction(trans)
        } else if trans.transactionState == .failed {
            print("failed!")
            print(trans.error)
            SKPaymentQueue.default().finishTransaction(trans)
        }
    }

Found in Apple developer website, here

-1

I had to go to Settings > iTunes & App Stores, then scroll to the bottom to the "Sandbox Account" field and Sign out from there. Now it is working!!!

enter image description here

astro4
  • 179
  • 1
  • 4