Testing a Store
During development, you should test your application to ensure that purchases are working correctly. However, you do not want to charge users while testing your application. Apple provides a sandbox environment to allow you to test your application without creating financial transactions.
The Sandbox Environment
When you launch your application from Xcode, Store Kit does not connect to the App Store. Instead, it connects to a special sandbox store environment. The sandbox environment uses the infrastructure of the App Store, but it does not process actual payments. It returns transactions as if payments were processed successfully. The sandbox environment uses special iTunes Connect accounts that are limited to In-App Purchase testing. You cannot use your normal iTunes Connect account to test your store in the sandbox.
To test your application, create one or more special test accounts in iTunes Connect. You should make at least one test account for each region that your application is localized for. Detailed information about creating test accounts can be found in iTunes Connect Developer Guide.
Testing in the Sandbox
Follow these steps to test your application in the sandbox.
Log out from your iTunes account on the test device.
Before you can test your application, you must first log out of your regular iTunes account. iOS 3.0 includes a Store category in the Settings application. To log out of your iTunes account, exit your application, launch the Settings application and click the Store icon. Sign out from the currently active account.
Launch your application.
Once you have signed out of your account, exit Settings and launch your application. As you make purchases from your application’s store, Store Kit prompts you to authenticate the transaction. Log in using your test account to approve the payment. No financial transaction takes place, but transactions complete as if a payment was made.
Validating Receipts in the Sandbox
You may also validate receipts created by the sandbox environment. The code to validate a receipt received from the sandbox is identical to that for the regular App Store, except your server must direct the request to the sandbox URL.
NSURL *sandboxStoreURL = [[NSURL alloc] initWithString: @"https://sandbox.itunes.apple.com/verifyReceipt"];
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)