In-App Purchase Error Code 0

in-app-purchase, ios, objective-c, storekit

Solution

This error can also be caused by trying to use the incorrect iTunes Connect test account. If you attempt to use a test account for another team than the one the app you are testing is registered to, it will cause the same error with no more specific message.

Problem

I'm trying to troubleshoot why I'm getting "Cannot connect to iTunes Store" with error code 0. I know my app identifier is fine because I retrieve product information on app launch and log the results and I get the correct product identifiers and prices from iTunes. When I change my app identifier to something stupid this fails. I know my product identifiers are fine as well for the above reasons (it wouldn't work otherwise and I double checked). I have tried firing the purchase by creating an SKPayment in 2 different ways: FIRST WAY ``` SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier]; // This is deprecated in ios 5 but should work [[SKPaymentQueue defaultQueue] addPayment:payment]; ``` SECOND WAY ``` SKPayment *payment = [SKPayment paymentWithProduct:foundProduct]; [[SKPaymentQueue defaultQueue] addPayment:payment]; ``` (foundProduct is from the array of SKProducts that get returned from an SKProductsRequest) Both ways fail with error code 0. I've tried this both on my iPhone 4S running iOS 5.0.1 and in Simulator on iOS 5. I've read that hard resets work (2359739) which seems insane, but I went ahead and tried it in Simulator (iOS Simulator => Reset Content and Settings...) to no avail. Only thing I can think of is that maybe the iTunes sandbox servers are being wonky...

Original source

Related problems