Error when purchasing IAP: "Cannot connect to iTunes Store"

Hey guys,

This error is driving me crazy.

I’m trying to make a purchase of an IAP item, and I keep getting this error message:

transaction.errorType = unknown

transaction.errorString = “Cannot connect to iTunes Store”

I’ve tried all these options to fix it, without success:

  • Logging out from the store, and logging in with a test user when trying to purchase

  • Creating a new test user, in case my old ones were malfunctioning.

  • Changing “com.company.appname.myIAPitem” to “myIAPitem” only.

  • Using an ad hoc distribution profile to build the project

  • Resetting my iPhone

  • Resetting all Settings

No luck.

It actually fails on my three devices (iPhone 4, iPhone 5 and iPad 2) under iOS 7, 6 and 5.1.

Also worth mentioning, it was working a few months ago, the last time I tested my project.

Any clue?

Thanks

I finally found the problem. I didn’t set the correct CFBundleIdentifier in build.settings

I build two apps with the same code, a paid one and a free one, and I was forgetting to change the Bundle Identifier when building my free app, which is the one that has the IAPs.

I had this:

CFBundleIdentifier = “com.mycompany.myapp”

Forgot to change it to the free version bundle identifier:

CFBundleIdentifier = “com.mycompany.myappFREE”

Hope this guides somebody else that finds trouble with IAPs!

It’s always those little things…

You saved my day! I was having the same problem and didn’t notice it until clients started to complain that they couldn’t purchase my in-app! Although i tested it before and worked.
 
Just to add on a bit, the “CFBundleIdentifier” in build.settings must match “Bundle ID”  in iTunes. See the screen shot below.
 
Hope someone in Corona can update their documents to inform users that “CFBundleIdentifier” is a must for in-app.

I would recommend not putting the CFBundleIdentifer in your build.settings.  Instead depend on the right provisioning profile.  It’s too easy to put the CFBundleIdentifier in your build.settings and forget that it’s there and then you build with a provisioning profile that doesn’t match and it creates other errors that are harder to track down.   Set it in the build screen that matches the profile you are using.

Rob

Hey Rob,

How do you exactly do that? Just remove the CFBundleIdentifer line in build.settings, and the build with get the bundle ID from the provisioning profile you’re using to build?

Yes.  When you hit the build screen (CMD-B) There will be the entry for the “Code Signing Identity”.  This is where you pick the provisioning profile.  That profile has to have an App/Bundle ID associated with it.  Its that App/Bundle ID that iTunes Connect knows about.  You cannot use the team provisioning profile for this.  It’s got to be a live AppID that both iTC and the Provisioning Portal knows about.

If you hard code it in build.settings, it’s too easy to get a mis-match along the way.

Rob

I finally found the problem. I didn’t set the correct CFBundleIdentifier in build.settings

I build two apps with the same code, a paid one and a free one, and I was forgetting to change the Bundle Identifier when building my free app, which is the one that has the IAPs.

I had this:

CFBundleIdentifier = “com.mycompany.myapp”

Forgot to change it to the free version bundle identifier:

CFBundleIdentifier = “com.mycompany.myappFREE”

Hope this guides somebody else that finds trouble with IAPs!

It’s always those little things…

You saved my day! I was having the same problem and didn’t notice it until clients started to complain that they couldn’t purchase my in-app! Although i tested it before and worked.
 
Just to add on a bit, the “CFBundleIdentifier” in build.settings must match “Bundle ID”  in iTunes. See the screen shot below.
 
Hope someone in Corona can update their documents to inform users that “CFBundleIdentifier” is a must for in-app.

I would recommend not putting the CFBundleIdentifer in your build.settings.  Instead depend on the right provisioning profile.  It’s too easy to put the CFBundleIdentifier in your build.settings and forget that it’s there and then you build with a provisioning profile that doesn’t match and it creates other errors that are harder to track down.   Set it in the build screen that matches the profile you are using.

Rob

Hey Rob,

How do you exactly do that? Just remove the CFBundleIdentifer line in build.settings, and the build with get the bundle ID from the provisioning profile you’re using to build?

Yes.  When you hit the build screen (CMD-B) There will be the entry for the “Code Signing Identity”.  This is where you pick the provisioning profile.  That profile has to have an App/Bundle ID associated with it.  Its that App/Bundle ID that iTunes Connect knows about.  You cannot use the team provisioning profile for this.  It’s got to be a live AppID that both iTC and the Provisioning Portal knows about.

If you hard code it in build.settings, it’s too easy to get a mis-match along the way.

Rob

Make sure the following settings are set for inapp purchase to work:

  1. go to iphone or ipad Settings>Game Center and enter the Test user 's  Apple ID and password

  2. go to iphone or ipad Settings>iTunes & App Store and use the same Test User’s Apple ID and password

I think most people fail because they entered different account for ipad Settings>Game Center and Settings>iTunes & App Store.

Make sure the following settings are set for inapp purchase to work:

  1. go to iphone or ipad Settings>Game Center and enter the Test user 's  Apple ID and password

  2. go to iphone or ipad Settings>iTunes & App Store and use the same Test User’s Apple ID and password

I think most people fail because they entered different account for ipad Settings>Game Center and Settings>iTunes & App Store.