I'm trying to test in app purchases in our app but I'm not having any luck. Part of the problem may be due to the expected sequence not being documented anywhere. Here are the steps I followed to support in-app purchases:
- Create test user in iTunes Connect.
- Log out of the Store on the device.
- Build and run the app in Xcode using a non-wildcard App ID and provisioning profile targeting the device (an iPhone 4 running iOS 4.2.1). I've run through this building for both debug and ad-hoc release.
- Make an in-app purchase.
- Alert is displayed: "Confirm Your In AppPurchase" with two buttons - Cancel and Buy. Tap the Buy button.
- Alert is displayed: "Sign In" with three buttons - Use Existing Apple ID, Create New Apple ID, and Cancel. Tap the Use Existing Apple ID button.
- Alert is displayed: "Apple ID Password" with two text fields and two buttons - Cancel and OK. Enter the email address and password for the test user and tap the OK button.
Here is where my understanding of what is the expected behavior is deficient. Here is what I see at this point:
- Alert is displayed: "This Apple ID has not yet been used in the iTunes Store. Tap Review to sign in" with two buttons - Cancel and Review. In all the documentation, blog posts, and forums, no one has mentioned this alert. Is this supposed to be displayed? I tapped the Review button.
- I am now taken to the App Store app and taken through a series of steps to confirm the account.
- The first page is titled "Confirm Your Country or Region" with a single value titled Store set to United States. I tapped the Next button on the toolbar at the bottom.
- The second page is to agree to the terms and conditions and the Apple privacy policy. I tapped the Agree button on the toolbar at the bottom.
- Alert is displayed: "I have read and agree to the iTunes Store Terms & Conditions." with two buttons - Cancel and Agree. I tapped Agree.
- The third page is to confirm information for the account (email, password, security question, birth date) and enable/disable iTunes store subscription information. It requires me to enter the year (why didn't iTunes Connect just ask me for it!). I entered the birth year and then tapped the Next button on the toolbar at the bottom.
- he fourth page asks is titled "Billing Information." This is when I realized something was wrong. All the documentation, blogs, and forums say I shouldn't be asked for a credit card.
Q1: What exactly should I expect once I enter the test user email address and password (the first set of steps)?
Q2: Why am I being asked for all this extra information for a test user? What should I be looking at to troubleshoot this?
Thanks for your help.
It happens when you install your development application over downloaded from App Store.
To fix this issue, you need to remove application from the device and install fresh copy using XCode.
iOS caches distribution profile somehow and requires production user if the first installation was done through App Store. With no regard what installation method was used recently.
Here is the trick (at least if worked for me..).
First log out of your real iTunes account in Settings > Store > Apple ID. You must be logged out of an account to be able to use your test account.
However, don't log in to your test account on that screen.
Go to the app, initiate your in-app purchase, and enter the test account email and password there. Assuming the test account is set up correctly (!), that should work.
Then, when finished testing, go back to Settings > Store > Apple ID and log out of the test account.
This sequence worked for me. I tried all of the above sequences and they failed for me.
- Sign out of your account on the iPhone in Settings -> Store
- Delete your test app
- Power the iPhone off and on again
- Close iTunes on your computer
- Run the app again from XCode
Thanks to OmegaDelta's blog for this one:
http://omegadelta.net/2011/05/11/testing-in-app-purchases-in-ios-4-3-sandbox/