I am using StoreKit for in app purchases in my iPhone game. The purchases all work correctly, however I am constantly being prompted when the app is opened to sign into an account which does not exist anymore.
I had one sandbox account that I used until I was getting an error in which pressing 'restore purchases' was restoring the purchase even if the user pressed 'Cancel' on the modal popup. Because of this I created a new sandbox account to try and restore purchases from an account which had not made any purchases. Unfortunately restore purchases still worked in this situation which is of course a problem. I thought it could be an issue with the old sandbox account still being on the device somewhere so I deleted it. For some reason, every time the app starts, I am still prompted to sign into this test account that has been deleted.
Research has lead me to believe that maybe somewhere a transaction was not finished and so it is trying to complete it every time the app starts? Does this sound plausible?
If you would like to see my code, let me know and I will update.
Edit: I have of course tried deleting the app and reinstalling and also signing out of all accounts along with a reboot of the device.
Research has lead me to believe that maybe somewhere a transaction was not finished and so it is trying to complete it every time the app starts? Does this sound plausible?
Not just plausible, but likely. Hack your app to call finish on all transactions regardless of actual completion state, then un-hack it.
To solve this I finally signed into the account it was prompting me to sign in to and then went through and purchased all of my IAPs again manually, this reset whatever hung action there was and fixed the issue.
I am testing In-App Purchases in Xcode.
I have set up a test account as per apple documentation. My problem is that every time I go into the background and then come back into my app I get prompted for my test App Store password. However, as far as I can see I am not calling any of my In-App Purchase functionality.
Is this a quirke of the testing environment?
I've tried re-specifying my original "proper" App Store userID/password in General settings but I still get prompted for my test App Store password on entering my app from the background again. Once I have put in the password everything is OK until I enter from the background again and then if it doesn't ask me for it again.
I haven't included any code because as far as I can see none of my In-App Purchase code is being accessed when I get this behaviour
Here is the reproduce steps of issue:
I tap the "purchase" button in my app.
I enter the password of Apple ID.
Apple show a dialog to confirm purchase or not. And I tap "Yes."
Apple show a dialog to say that I have no payment information, need to complete it.
(This moment I got a transaction with state SKPaymentTransactionStateFailed in updatedTransactions: function)
I tap continue then jump to iTunes app and start to complete my credit card information.
After complete the payment information , apple ask me to confirm purchase again.
I tap "confirm" then the purchase is done.
(Notice that it didn't come back to my app automatically.)
Here is my questions:
Why this flow didn't invoke the callback function I wrote when transaction with state SKPaymentTransactionStatePurchased is coming?
The last one, do I need to finish transaction when I receive transaction with state SKPaymentTransactionStateFailed?
In my experience, if you're in the sandbox and are asked for credit card info, something is wrong. Could you try to log out of your App Store account before you build/run the app? That usually solves it for me. If that doesn't work, you might try deleting the app as well as logging out before running the app again. Are you making sandbox purchases with a test user created through iTunesConnect?
According to SKPaymentTransactionObserver Protocol Reference, yes, you should call -finishTransaction: even for SKPaymentTransactionStateFailed. I do this in my own projects with no ill effects.
I have signed out from the store in device settings.
I entered user credentials only in my App.
I have set up a brand new (actually around 4 times) test user.
Why this message keep poppin' up?
Is it something connected to iOS 5, automatic app sync, or iCloud?
I had exactly same problem with sandbox in-app purchases, in built-in model (no receipt verification), app received valid products, now i called addPayment, everything alright. But now "Verification required" appeared and payment was canceled.
After hours of pain I discovered, my problem was in test account.. i created test account for Czech Republic iTunes store... and that was the reason of fail. Dumb.
I tried to create Canadian test user and it suddenly worked! "Verification required" will no longer appeared.
I've dealing with this problem for about one week, trying to use accounts in US/Canada without any success. Finally I found this post and it works:
http://iphonedevsdk.com/forum/iphone-sdk-development/63008-in-app-purchase-test-account-verification-required-cant-get-passed.html
You need a test account that NEVER has a credit card attached to it, NEVER is logged into itunes store or app store via device, and if you do login to itunes or agree to any app store stuff it voids the test account and will never work again.
So, To test your In App Purchase app, you need to use a new account that does not have a credit card. logout of the store, and only use your new account inside the app you are testing.
Update: After a long time system maintenance of iTunes in Sept 2013, only test accounts in US can make test purchases.
I have struggled with this myself, i finally found a workaround that worked for me...
On the device Log out of iTunes account in settings (also hard close settings and iTunes if you have them open as a precaution)
Delete app
Create a new test user at “itunesconnect.apple.com” – selecting the United States as your store
Reinstall app
Try to make a purchase in the app
Enter you new test user account details
If a pop up states that it needs to swap stores, immediately press home. DO NOT press OK.
Relaunch the app, and try again. It should now work as expected.
Hope this works...
In addition of the above answers, note the below points also :-
1) Uninstall your app from the device.
2) Create a new test account on iTunes Connect and verify its email address. Never add any payment information for this test account, not online, not on iTunes, not on your device. Doing so might invalidate your test account (and trigger the "verify payment info" vicious cycle.) Also never use this test account out of the Sandbox.
3) Log-out from the App Store on your device. DO NOT log back in the App Store via Settings > iTunes & App Stores on your device. You will be asked your login credentials from your app later (see points 5-6)
4) Re-install your app.
5) Attempt an in-app purchase. You should now be prompted to enter both your username and password (as you logged out from the App Store)
6) Type in your username and password: you should not see the dreadful "Verification Required: before you can make purchases, you must verify your payment info" message and the purchase should be successful.
Even in sandbox, you need to complete the buy verifying the receipt to the server.
It corresponds to steps 6-7-8 of built-in model and 11-12-13 of the server model.
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/APIOverview/OverviewoftheStoreKitAPI.html
All you need to do is:
Retrieve the receipt data from the transaction’s transactionReceipt property and encode it using base64 encoding.create a json like this:
{
"receipt-data" : "(receipt in base 64 encoding)"
}
Make a post to verification URL for production:
https://buy.itunes.apple.com/verifyReceipt
For sandbox :
https://sandbox.itunes.apple.com/verifyReceipt
The response is like this:
{
"status" : 0,
"receipt" : { ... }
}
If the value of the status key is 0, this is a valid receipt.
If the value is anything other than 0, this receipt is invalid.
For further information look the guide:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/VerifyingStoreReceipts/VerifyingStoreReceipts.html
Swift 3
Insert this temporary code somewhere in your project:
for transaction: AnyObject in SKPaymentQueue.default().transactions {
guard let currentTransaction: SKPaymentTransaction = transaction as? SKPaymentTransaction else {return}
SKPaymentQueue.default().finishTransaction(transaction as! SKPaymentTransaction)
}
This clears out the payment queue. Make sure to run it much later than viewDidLoad if you can. I made mine triggered by a button. Ran it a couple times, then removed the code. No more annoying verification pop-ups.
I saw this issue after iOS5 got released.
Earlier I used to create test accounts with dummy email addresses and it used to work well for me, but post iOS5, it started showing verification required for test accounts.
Thus I ended up using actual email addresses for the test accounts and verified when asked for, which seemed to do the trick for me.
I was facing same problem after spending several hours i figured out that county/region of your itunes connect test account and your device/simulator must be same.
Please verify it as it solved my problem
Register a fresh test user for the USA. You can put any email address.
Log out under settings.
Delete the app.
start it again via xCode
login with your new user within the app.
It may say that you are not located in the USA and it opens the browser, Close the browser and start it again.
It should work now.
If you are having such problem for 4th IAP item to buy.
It looks, each test account does not work for purchasing more than 3 items of an application. You may create a new test account from itunesconnect.apple.com->Manage Users->Test User to test your 4th IAP item.
Creating a canadian test user solve this issue.
We are encountering an occasional issue which runs thus:
A user's first purchase on a new device happens to be an IAP using our app
iOS asks them to confirm their credit card details because they've not used the device before.
It appears to take them to the App Store app to fill in these details
When they've done this, they are left sitting in the app store
If they manually return to our app, the purchase has failed, but they have been charged
Restarting the app doesn't help
We have spotted revisions which should help, but has anyone else had an issue with iOS not coming back to their app in this situation, and possibly therefore not communicating the purchase success?
What is the IAP process if a user returns to the app manually?
So I'd recommend having your coder come here and maybe talk a bit about how you're implementing StoreKit. The system is designed to cope with edge cases where users are taken away from the app and don't go back, but you have to implement the SKPaymentTransaction observer correctly. A common mistake initialise the transaction observer when the user goes to purchase an item, but this is wrong. The observer needs to be around from application launch.