Can not log into sandbox by test account on iOS - ios

I am implementing in app purchases for my app. I am logged out from AppStore, created some test accounts, have not verify it by e-mail.
And every time I tried to log in into sandbox app-purchase I got an transaction error. Btw product info restored correctly.
Looking deeply I notice that after any attempt to log in, my AppStore account setting in device filled with the info from this test account! So I think it tries to log in into real AppStore instead of sandbox.
What am I doing wrong? Why my test accounts tries to login into the real AppStore and how to fix it?

To know if you're in sandbox environment or not, you can have a look at the purchase popup. If you can read "[Sandbox environment]" at the bottom, then it means you're using the sandbox. Otherwise, you're using the real Appstore (But I'm pretty sure it's not the case since this is automatically chosen by the device).
Anyway, it seems that Apple Sansbox environment is experiencing some problems today.
For example, I have an app that was dealing correctly with inapp purchase yesterday. Today, only retrieving SKProducts was ok.
I recommend you to be patient until the problem is fixed by Apple.

Related

In App Purchase: Sign in required [Environment: Sandbox]

I unfortunately typed my real production account to purchase an IAP in the sandbox environment.
Since then, I am getting annoying alerts the whole day, which constantly ask me to sign in to my account.
The account textfield is prefilled with my production account, so there is no way to fill in a new sandbox account.
This happens with the production version from the app store and the debug version. If deleted, it doesn't appear anymore.
Does anyone know what to do to fix this issue?
Thanks in advance.
Cheers.
I had the exact same issue and worked around without factory default doing this.
I force closed all app, then loged out of iTune and App store only. Rebooted the phone. After restart, make sure to double check if it still loged out of iTune and App store before starting the app. Once the app has been started without user logged in it fixed the issue and i was able to log back Apple account’
I solved this problem by completely wiping my iPhone, without restoring my data from a backup. Sad.

How to verify if an iOS sandbox account is valid still?

I'm having some issues with sandbox users. According to Apple's docs
Important: If you mistakenly use a sandbox tester account to sign in to a production environment, like iTunes, on your test device instead of your test environment, the sandbox account becomes invalid and can’t be used again. If this happens, create a new sandbox tester account with a new email address.
In my case I haven't tried to login to the production environment with these accounts, but am still getting the invalidated somehow. It seems they will be good for a day or two, and for the first couple purchases and then stop working.
I'm getting back SKErrorDomain Code: 0 NSLocalizedDescription: Cannot connect to iTunes Storemost times when I try to purchase.
Most recently I even got "You are not authorized to make purchases of this InApp Purchase in Sandbox at this time. [Environment: Sandbox]"
I'm very flustered by these errors because it seems that it will work fine and then intermittently stop working. Has anyone found a way to successfully verify if an account is invalid, or found a way to get past these issues?
Each time I run into this problem, these steps typically clear it:
Make sure phone is signed out of all services (iCloud, App Store, everything)
Restart the phone.
Remove the app from phone and re-install via Xcode
When the app prompts for credentials during in-app purchase, enter sandbox credentials.
There is the very off chance that the sandbox account must accept some new terms from Apple. Log-into developer.apple.com and make sure you don't have any lingering alerts for that account.
Best of luck!

Testing In-App Purchase on iPhone

I have setup my app to use In-App Purchases. All the necessary steps have been done and everything works except for one thing, the final step for completing the purchase transaction i.e. SKPaymentTransactionState always completes with Failed every time.
So I did some research and found another post that said not to test this in the simulator and do it on a physical device as it seems there is a limitation placed on making purchases in the simulator by Apple on purpose.
So I went back to try to run this on my physical iPhone instead. The problem I'm having now is that my physical iPhone is linked to my active iTunes account. When I try to make a purchase on it, the User ID is already defaulting to my active ID and it only asks for my password.
So my question is (1) How do I force the phone to ask for me to enter a new User ID and Password so that I can use the Sandbox User I created in iTunes Connect? (2) I am a little nervous about even entering a secondary iTunes credentials, can anyone validate what the behavior is like? I do not want my active iTunes account to have any issues, it is possible to run both my active iTunes account and the sandbox user on my physical device with no issues?
Log out of iTunes on the phone via Settings, but wait for the app to prompt you to log in before entering your sandbox account credentials. NOTE that I'm referring to iTunes, not iCloud. It gets more interesting if you need to do that.
When you're done testing, log out again via Settings but differently than before, go ahead and re-log in via Settings to your "regular" Apple ID to return to production use.
You can't run them "simultaneously" as such but you can use your regular device to sandbox test without problems.

In-App-Purchase behaviour using a real Apple ID

Clarification
I know, there are tons of questions about In-App-Purchases, some of them also about dealing with real Apple IDs, but I found none with a really precise answer about the exact behaviour / errors you get, doing so.
The actual question
I have an app with IAPs, whenever I try to log in using my real Apple ID, and the app is asking for products / prices or trying to buy something, I get the following error popups.
Entering the valid password
Entering a wrong password
Already logged in when starting the app (in Settings => iTunes & App Store)
Can someone please confirm (or refute) this to be the expected behaviour?
To summarize the question(s)
Is it correct, that real Apple IDs only work in distribution signed apps (for/from the AppStore) and won't work in development signed apps?
Sandbox Accounts work in a Sandbox Environment no matter how the app was signed?
Is it correct, that real Apple IDs only work in distribution signed
apps (for/from the AppStore) and won't work in development signed
apps?
Yes. You can't use real apple IDs' in your sandbox environment.
Sandbox Accounts work in a Sandbox Environment no matter how the app
was signed?
Test users created under your account will work with the development build. It won't work with production builds which are downloaded from Appstore.
P.S. You can use a dummy email to create sandbox testers (not sure whether it still works :) )
https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SettingUpUserAccounts.html#//apple_ref/doc/uid/TP40011225-CH25-SW10
When I implemented iAP last month I got exactly the same experience. It all worked perfectly once the app was signed and released on AppStore so you should be safe.
The sandbox account works only in a sandbox environment and will not work if you download the app from the AppStore.

iPhone In-App Purchase Store Kit error -1003 "Cannot connect to iTunes Store"

I've been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid purchase (so I guess the normal cycle of receiving paymentQueue:updatedTransactions and calling finishTransaction was interrupted).
Now I am unable to successfully complete any transactions and instead am getting only transactions with transactionState SKPaymentTransactionStateFailed when paymentQueue:updatedTransactions is called.
The transaction.error.code is -1003 and the transaction.error.localizedDescription is "Cannot connect to iTunes Store"!
I have tried removing all products from iTunesConnect, and rebuilt them using different identifiers but that did not help. I have also tried using the App Store app to really connect to the real App Store and download some apps so I do have connectivity. Finally, I have visited the Settings:Store app to make sure I am signed out of my normal app store account.
I had a similar situation and dumped the iPhone's network traffic to see what's going on. I found that the normal store was contacted instead of the sandbox. It helped to delete the app from the device, make clean and build/install it again. Apparently something with the development profile had gone wrong.
Update: To dump the network traffic of a non-jailbroken iPhone, just use Internet Sharing on your Mac and configure your iPhone to use your Mac's WiFi. Then tcpdump -n -i en1on your Mac will do the trick.
If you're getting error 0 "Cannot connect to iTunes Store" (which I realize is not the error -1003 that OP asked about, but a web search for error 0 also leads here), this can be caused by two possible problems:
You're passing in the wrong product identifier. If that's the case, then you'll get error 0 shortly after calling -[SKPaymentQueue addPayment:], before you get the popup asking you to confirm payment.
Your test user has become invalidated. This can happen if you accidentally log into the App Store with your test user. When this happens, you'll get error 0 after entering your password to confirm your payment.
To fix problem #1, pass in the correct product ID. To fix problem #2, create a new test user on iTunes Connect, and optionally delete the old test user.
I had a similar issue, was getting "Cannot connect to iTunes Store" with Code=0. This is how I solved it, after trying every other ritualistic piece of advice found on the Internet from re-downloading my certificates to resetting all my device settings to sacrificing a virgin black goat:
In the target summary for the app, I used to have my version number in the "build" field, but nothing in "version" field. This seemed odd to me, so I moved the version number from "build" to "version". This resulted in the aforementioned error. Moving the version number back to "build" solved the error.
Add new test user for your app.
Make sure you have correct date and time set in the Settings. otherwise it fails to make a SSL conenction to the store!!
I had the same error, and after reading through some threads on the developer forums, I reset the settings on my device (Settings->General->Reset->Reset All Settings), which cleared it up. It seemed drastic, but it worked.
I had the same error that seemed to pop up out of nowhere (was working fine one day, but then the next day it was giving me these errors about 2 out of every 3 times I tried testing my in-app purchase).
Then I visited the App Store (when trying to make another real purchase), and realized that they had a new user agreement that they wanted me to verify. After I did that, when I went back to my own app and tried out the test purchase again, it was working fine and have had no errors since. So I suspect I was getting the error because they wanted me to verify the new user agreement.
Now the only thing I wonder is if there is a way for my in-app purchase to forward that prompt to my users instead of giving them a mysterious error?
What worked for me was to uninstall my app from the test device, then install a fresh copy from Xcode.
In SKPaymentTransactionState tells that SKPaymentTransactionStateFailed before your request is added to server queue.
#class SKPayment;
enum {
SKPaymentTransactionStatePurchasing, // Transaction is being added to the server queue.
SKPaymentTransactionStatePurchased, // Transaction is in queue, user has been charged. Client should complete the transaction.
SKPaymentTransactionStateFailed, // Transaction was cancelled or failed before being added to the server queue.
SKPaymentTransactionStateRestored // Transaction was restored from user's purchase history. Client should complete the transaction.
};
typedef NSInteger SKPaymentTransactionState;
And on SKPaymentTransaction Class Reference Error Discussion says:
The error property is undefined except when transactionState is set to SKPaymentTransactionStateFailed. Your application can read the error property to determine why the transaction failed.
So, transaction.error.localizedDescription is "Cannot connect to iTunes Store"! is a general error message.. I am also getting this error message regularly while testing my InApp Purchases.
Some tips u can do is,
Retrieve all products from app store using SKProductsRequest and check its response.products contain your requested productIdentifier.
for this use,
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[objProducts allKeys]]];
//pass product identifier array as argument
[request start];
And Catch response in :
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
NSArray *myProduct = response.products;
}
So that you can decide is you can communicate to app store. and your product id is there.
Make sure that you use In App test user account for testing.
And you use the same app-id provisioning that you configured In App purchase.
thanks
I fiddled around with going to the App Store and then back to Settings/Store to Sign Out. I did this 3 times, revisiting my app each time and adding debugging NSLog output, and now I am able to continue testing my in-app purchase code without error -1003. I am not sure the exact reason for this working again, but I am fairly certain is is not a code change on my part as all I was doing was adding NSLogs and re-running my app.
Yeah, IF you've connected your iPad/iPhone to a different computer initially, and are now using it on another, you absolutely must sign out of store on your iPad, sign in w/ normal account to ITunes on your MAC, then Sync.
Also, make sure your iPad "WIFI" is on...
I Did a Clean all Targets in XCode and manually deleted the application off my device, then Build and Run from XCode and it fixed a similar problem (Same error message but different error code:-1009)
Unfortunately, I ran into a problem that was not documented here. In-App-Purches will not work until you accepted all contracts related to app- and in-app-purcheses. So make sure you (or your customer) set up all contracts in iTunesConnect properly, they must appear in the "Contracts In Effect" section to make your purchaes work.
Our problem was that in Itunes Connect we had the wrong bundle identifier. Someone had created the app before hand and we had to edit the app and set its appId to the new one.
I had two problems that caused this:
1) I had copied the IAP code from a different (working) app but had missed setting up my observer:
observer = [[IAPHelper alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
2) I was logged in to iTunes in the settings of my device. You can only use a test user in the sandbox - I logged out and it worked again.
Just log out your iTunes account (don't login your test account now! ) , and start your program. When inapp purchase it ask your login details, you must enter your test account information.
I tried every solution offered in the thread here, but to no avail. In my case, I had a wild-card bundle identifier starting with the same domain name as the one I used while creating the bundle identifier for in-app purchase provisioning profile.
Here is how I fixed the problem and may help you fix yours (See attached):
1) Connect your iPhone to Mac.
2) Under the "Devices" (in Xcode > Window menu > Organizer window) select the "Provisioning Profiles" option for your iPhone. You will see all provisioning profiles currently residing on your iPhone.
3) Carefully remove all provisioning profiles starting with the particular domain name in the bundle identifier (com.MYDOMAIN.*) especially the ones that use wild-card except for the one you create specifically with the ability to do In-App purchase (com.MYDOMAIN.inappidentifier).
4) Install the app afresh and test your implementation with a fresh iTunes connect test user (sandbox)
SCREENSHOT:
I have been stuck for 2 days, here's my solution:
Remove all in-app-products.
Remove new in-app-products.
Create a sandbox tester.
Log out my apple account from device (iPad), and then try to buy the product.
It will ask for login, then re-login with the sandbox tester account.
Purchase goes through.
I think the importance is the sandbox tester account, I have not used it before since I always got error-0.
In my case,
I tried everything in the internet, but nothing worked.
Apple actually broke the production payment system, and the sandbox. I just had to wait two days, and it started to work.
The In-App Purchase FAQ says:
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 Xcode simulator. It started working when I used my device.
Even in the In-App Purchase Programming Guide says to use the development iOS device has a suggested testing step.

Resources