When should i validate in-app purchase transaction receipt? When should i validate in-app purchase transaction receipt? ios ios

When should i validate in-app purchase transaction receipt?


Scenario 2.If the internet blows up, you won't get to -finishTransaction.But that's cool, cause you can retry (NSTimer) and your app will be given the unfinished transaction on start up.And that's exactly how StoreKit is designed to work (even though it's not obvious from reading the docs).

StoreKit comes with transactions, for a good reason. The user can simply quit the app right after purchasing, and you still have to recover from that.And that's why Apple recommends to set your transaction observer as soon as possible in the app lifecycle.

Don't ever finish the transaction before providing the content, you'll have to implement your own transaction system on top of StoreKit, and you don't want to do that, believe me (I've seen it done, it was a disaster).

Edit: in all honesty, the eventually of a user turning the internet off after purchase and before you validate is ridiculously low. The guy was on they internet a second ago, nobody just goes out to cut the internet in the middle of a purchase.But it's possible that the user gets interrupted at that the moment and send your app to the background.Your app can then get killed for whatever reason iOS deems appropriate.And when you're apps starts again, well your app won't remember having a purchase to start with, and store kit won't be of big help, since you've already finished the transaction.


This is what I do:

  1. App sends a request for the downloadable content, with receipt attached as an argument.

  2. The server validates the receipt with iTunes, and if it is valid, it returns the purchased content as the response body to the original request.

This way, even if the app binary is hacked/modified, the content is downloaded only against a valid receipt (because no modifications made on the client app can possibly interfere between my sever and Appleā€™s).


I'd verify first. It takes 2-3 seconds. You can use ReceiptKit https://github.com/maciekish/ReceiptKit for this purpose.