Testing In App Purchases - Cannot Connect to iTunes Store - ios

I'm returning to some code I wrote in 2012. Back then, I had created a wrapper for the StoreKit framework that also did receipt validation using the sandbox URL for iTunes.
Since it's been so long, I looked through the StoreKit docs and AFAIK, nothing's changed.
For some reason, I can't test my In App Purchases anymore because I get the above error (Cannot Connect to iTunes Store) and the sandbox servers seem to be down (http://sandbox.itunes.apple.com/).
It's been down for the past 2 days. Is this normal? Or has the process for testing changed since when I first wrote this code?

In most of the cases like this, if you test it out in simulator (iOS 6/7/8) - you will get more about the error using [error localizedDescription].
The reasons can be numerous - most of the time it is caused by nonsandbox user. But it can be caused by reasons like app ID not matching that on itunes connect server too.

Related

Unity Codeless IAP IOS build rejected

I have a problem using Unity's codeless API in conjunction with IOS.
Apple keeps rejecting the build with the following message:
Guideline 2.1 - Performance - App Completeness
We found that your in-app purchase products exhibited one or more bugs
when reviewed on iPad running iOS 12.1 on Wi-Fi.
Specifically, no action takes place when we initiate the purchase.
Some notes:
I succesfully built and published the app on android.
The IOS version works with the uploaded build. I can make in app purchases when i run the app on my iphone.
I have filled in all the required legal/ financial information and have a valid contract for purchases as defined in the ios docs.
The build is set as "release" and "development build" is NOT checked.
After rejection by apple, all the in app purchases in the developer console are marked as requiring action.
Specifically it is now showing that the localizations are invalid. However no further information is given. I suspect this is just because the build is rejected?
So, has anyone had a similar problem? Having the app run fine when using the development build on a local phone, but still having it rejected because of the aforementioned reason?
In the end i requested i call with Apple to discuss the rejection of my IOS build(s).
It had been rejected 3/4 times with the same reason.
The reason: A problem on their part. They suspect they had a misconfigured environment on their side, which resulted in a not working build on Ipad.
I did not have to upload a new build, they reused the last rejected one and it was approved within hours of my call.
I suspect that the developers might have been confused, seeing that the app was entirely in dutch. This can seriously cause some confusing, because the representative on the phone had trouble locating some IAP functionality himself like the restore button.
So should you have the same problem:
If your app is in a non-english language, specificy where the reviewers have to click for In App Products, where the Restore button is and similar key parts of your app.
Request a call with Apple if you are sure that you did everything correctly. Talking on the phone with them really helps speed up the review process and clarify any misunderstandings.

Check subscription status in iOS app Ionic 2

I am currently developing an in-app purchasing in Ionic 2 and each time the app is run I check if a user is subscribed. For Android I use restorePurchases function. For iOS I am trying to use getReceipt() function. What I get is a long Base64 receipt string.
My question is, how am I supposed to check if a subscription exists using that string?
Thank you in advance.
I am answering the implicit question of why this error could occur:
Many things can go wrong causing this error, which most of them has nothing to do with your code actually. just your setup. for this to work in a test device
You should be logged in that device using a iTunes Connect sandbox
account.
You should be logged in your Mac using sandbox account. (not sure why, but I read somewhere you have to, and I do it!)
The Bundle ID everywhere should match. that is in your iTunes Connect, your ionic app's Config.xml
should not have production version of the app on your device
hope others provide better answering explaining why this is so difficult to get to work!

In-App-Purchase invalid product id only on release version

I released a new version of an app yesterday which added in app purchases. We did testing with a test account in sandboxed mode and everything worked correctly, however once we download the app from the app store the SKProductsRequestDelegate method:
(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
returns invalid product id's instead of valid ones. I'm baffled because I've had these types of problems before but only when trying to get them to work in debug mode, never after the app has been released from the app store. I've double checked everything on the list here http://troybrant.net/blog/2010/01/invalid-product-ids/ and none of those are the problem.
Here's another thread which is exactly my problem but no solution here: iOS In App Purchase - "Invalid Product ID" in release, NOT development version
I also encounter this problem and after 22 hours the problem be fixed automated. So I think this is the app store's problem that apple need some time to add your iap ID in their server.
It turns out in app purchases are magic. At around 8 pm we noticed that things started working normally. We had previously filed a request for help from Apple but never received a response so I'm not sure if that's what kicked off the fix or if it was just one of those things we needed to wait on.
I am also suffering with this issue and I went to Apple Developer Forum to get the solution. The problem is might be with Review team's device or environment.
Here is the link of full thread: https://devforums.apple.com/thread/233371

"Cannot connect to iTunes store" when restoring iOS In App Purchase in iOS simulator

I've looked through the many existing questions related to "Cannot connect to iTunes store" issues with iOS StoreKit and I don't think my situation is covered:
When running in the iOS Simulator, I get the "Cannot connect to iTunes store" error after restoring a previous bought in app purchase. If I hit Cancel, the popup goes away and the restore is successful.
There is no problem at all when buying the in app purchase, only when restoring.
Also, the problem only occurs on the simulator, not when testing on a real iPhone.
I'm pretty sure everything is OK, just wanted to confirm that it is just a simulator bug. Any one else seen this one?
Having researched this as much as I can, and confirmed that there are no issues when running on a device, either in sandbox mode or (since yesterday, when the IAP was approved by Apple) using a real Apple ID, I'm assuming this is a simulator bug and can be ignored.
Contrary to the answer posted by iLive below, and repeated elsewhere on SO, testing IAP on the simulator is explicitly supported by Apple, except for hosted content downloads.
UPDATE: It would appear that since iOS 7, testing IAP on the simulator is no longer properly supported. I've had it working using the non-64bit simulator, but not with the 64bit iPhone simulator. Your milage may vary. As per pix's comment below, Apple also seem to have removed mention of iOS simulator testing from their documentation.
I do not believe you can test your purchases with the simulator.
From the "In-App Purchase Programming Guide":
Store Kit does not operate in iOS Simulator. When running your application in iOS Simulator, Store Kit logs a warning if your application attempts to retrieve the payment queue. Testing the store must be done on actual devices.
If you look at this link, Apple tells you about what you should do:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/DevelopingwithStoreKit/DevelopingwithStoreKit.html
You can also check out this link: restore button for in-app purchases error
Hope this helped!
I ran into the same problem. I would get the "Cannot connect to iTunes Store". If you press Retry it will send you to the login prompt. However, if you press cancel, you will get "Restore Purchases Successful". This does seem limited to the simulator.
https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/index.html#//apple_ref/doc/uid/TP40001051-SW241
StoreKit (In-App purchases) will not work in the Simulator. 13962338
Make sure you use an account which is an sandbox user. I tried to use my personal iCloud account on Sandbox which got rejected with the same error.
As of recent (Version 8 and onwards) Xcode releases, I'd qualify the state of StoreKit in the simulator as partially implemented.
Apple officially says you need to test it on the device, however some calls seem to supported in the Simulator – at least the SKProductRequest always works flawlessly. Completing a purchase may or may not work.

In App purchase in iOS suddenly stop working ( Error code=5002 occurred )

I have integrated in-App purchase in my application successfully. I tested it properly by making test user account in itunes. My in-app purchase worked fine. But suddenly my IAP stopped working.
App can load all of the products but after entering my account credentials then transection queue undergoes state SKPaymentTransactionStateFailed and gives an error
Error Domain=SSServerErrorDomain Code=5002 "An unknown error has occurred"
It seems that the storekit does not work in the simulator any longer. I quote from storekit docs:
Note: Store Kit does not operate in iOS Simulator. When running your
application in iOS Simulator, Store Kit logs a warning if your
application attempts to retrieve the payment queue. Testing the store
must be done on actual devices.
Store Kit Docs
If you are testing on real device, make sure it is not JB.
If you are testing on simulator, make sure you are running iOS 6.0 or above, lower version of simulator doesn't work, I wasted a whole day to figure this out...
It has been stopped working on simulator. try to use it on real device. It will work fine.
I've run into the same error on iOS Simulator, but it works on my device(iPhone 3G).
The error is returned from Apple's Server, it's not under control by us.
Facing the same problem in ios 5.1 the store kit dosent work on simulator anymore you need to check it in the device.
And even after connecting to the device say you get an error code "Cannot connect to iTunes Store"
then that means that your device cannot contact the apple store and that is something which is not your fault.
To fix this, sign out of any existing account in the Settings app on your device.

Resources