In-App Purchase--Testing a Store [7]

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.

Note: Store Kit does not operate in iOS Simulator. When running your application in iOS Simulator, Store Kit logs a warning if your application attempts to retrieve the payment queue. Testing the store must be done on actual devices.

 

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.

  1. 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.
    Important Do not sign in with your test account in the Settings application.


  2. 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"];

 

你可能感兴趣的:(store)