assay
assay

Reputation: 33

iOS in-app purchases: executing code after App Store's "Buy" confirmation button is tapped but before user is charged

My app has a large number of people purchasing a limited amount of consumables. I'd like to catch the moment a user confirms a purchase using the App Store's confirmation dialog and the "Buy" button, so that I can make a call to the server to ensure that the user can receive their goods and cancel the transaction myself (to avoid the user getting charged) if none exist (i.e. they were too slow).

I'd like to do this without saving a consumable for the user after they indicate a wish to purchase and only releasing it back to the pool of consumables if they cancel. Intercepting the moment when they commit to purchase and detecting whether or not any consumables still exist is really important to the overall competitiveness of the purchase (saving a consumable on my end for the user would allow the user to sit on the transaction's confirmation dialog screen indefinitely).

Does anyone know of any coding strategies that could perform such a unique task? I was trying to employ NSDefaultObserver but without much luck.

Upvotes: 3

Views: 198

Answers (2)

Linuxios
Linuxios

Reputation: 35803

Undo's answer is right, but I'd also like to point out that you could implement a "currency" system like many games do, where a user can buy amounts of "coins" or "credits" using IAP for real money, and then these credits can be used to buy these limited consumables using a completely custom and configurable system.

Upvotes: 1

Undo
Undo

Reputation: 25697

Unfortunately, there isn't any API that tells you when this happens. The IAP system is fairly opaque about the process itself, developers only really get status updates when the purchase succeeds, fails, or otherwise "finishes" (deferral, etc.).

I know this isn't the news you wanted, but I'm afraid it's true. It's awesome that you're thinking about these things, though! If I were you, I'd perform the check right after they hit the buy button in your app - in my experience, people tend to enter their credentials relatively quickly after deciding to purchase an item.

Upvotes: 1

Related Questions