I know this is an old topic, but I had trouble finding a solution and went through some mind-numbing trial and error until I figured out a solution so I thought I would share it here since I was unable to find it anywhere else.
First, make sure after every transaction you call:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
What happened in my case is that a transaction wasn't finished and stayed on the queue so even when I switched to a different sandboxed account it still continued to ask for my old account's password.
To fix it I added:
SKPaymentQueue *queue = [SKPaymentQueue defaultQueue];
for (SKPaymentTransaction *transaction in queue.transactions) {
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
BEFORE I added the transaction observer, ie this:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
Also, in the
(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
function, I added this line of code:
[queue finishTransaction:transaction];
in the SKPaymentTransactionStateRestored and SKPaymentTransactionStateFailed cases of the switch statement. Don't add it to the purchased state because you aren't allowed to call finish on that from what I know.
I'm not sure which of the two above steps fixed the bug because it persisted until I signed out of my iPhone, deleted the app, powered it down, and did a clean rebuild/install that it finally stopped asking me for the password to the bugged account. Hope this helps someone.
EDIT: (11/12/15)
So I found out the cause of breaking sandbox accounts. It happened after restoring purchases, then hitting the home key, reopening and hitting the restore button again which caused a crash. The restore stayed in the queue and the above process was the only way to get out of the popups asking for the password.
In order to stop that, I added:
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
to by tearDown function (called by applicationDidEnterBackground:) of my main view controller before I nil'd my in-app purchase manager object. I think what was happening is that I added the object as a transaction observer more than once and it was causing the odd behavior. From the looks of it, this seems to have fixed the problem entirely because I haven't been able to recreate the error again.
Best Answer
Well, i found a nice blog with a code library that allows to add an In-App Purchase to your free application. In the end the guy answers the question I've asked him there:
http://blog.mugunthkumar.com/coding/iphone-tutorial-–-in-app-purchases/
Shortly the behavior I'm experiencing is not a bug, it's a feature and iTunes also works this way. When you're sign out and sign in again, it says, that your purchases are valid only in the store you have account in and it takes you to that store.