The difference between production and sandbox environments is based on the link that you are calling.
#define ITMS_PROD_VERIFY_RECEIPT_URL @"https://buy.itunes.apple.com/verifyReceipt"
#define ITMS_SANDBOX_VERIFY_RECEIPT_URL @"https://sandbox.itunes.apple.com/verifyReceipt";
ITMS_PROD_VERIFY_RECEIPT_URL is production server. ITMS_SANDBOX_VERIFY_RECEIPT_URL is sandbox server.
- Make sure that you create the right provisioning cert from Apple provisioning portal. Know the difference between Ad-Hoc vs Distribution.
- When you are using a Test iTunes user account that you created from iTunes Connect to buy, you will have to test it under sandbox server. Under the Release of Code Signing Identity, you should choose Ad-Hoc provisioning rather that distribution provisioning.
- But when you want to release to app store, you have to choose distribution provisioning and also the production server (ITMS_PROD_VERIFY_RECEIPT_URL). You can not use test user account on this server. You will have to use a real iTune user account to buy it (after Apple approves it) to make a real purchase.
To Learn how to implement IAP locally and verify the receipt locally, learn from:-
1.http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial
2.http://www.raywenderlich.com/23266/in-app-purchases-in-ios-6-tutorial-consumables-and-receipt-validation
You may download the completed sample project here:-
3. http://cdn1.raywenderlich.com/downloads/InAppRagePart2Finished.zip
NOTE: There might be another way of verifying the receipt that I do not know.
I found something that might help:-
1. https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKReceiptRefreshRequest_ClassRef/SKReceiptRefreshRequest_ClassRef.pdf
- (id)initWithReceiptProperties:(NSDictionary *)properties
It says "In the production environment, set this parameter to nil."
properties
In the test enviroment, the properties that the new receipt should have. For keys, see “Receipt
Properties” (page 4).
In the production environment, set this parameter to nil.