Andrei Herford
Andrei Herford

Reputation: 18795

iOS in-app purchase receipt validation - What happens if server is down?

Assume a simple ToDo-List app can be connected to a web service account. The web services allows the user to edit his ToDo lists online and to sync the data accross different devices.

Now I would like consumable in-app purchase items to the iOS that allows the user to buy different pay-per-use features. For example "100 reminder push notifications" could be an IAP item...

Flowing the Apple docs the purchase would follow these steps:

Problem: What happens to the purchase if the server is down?

Even if the actual purchase result (add reminders to user account) would not be stored on the server but locally on the device, the receipt validation and purchase completion would fail if the server is down or if there is no internet connection.

However, from the point of view of the App Store the purchase is complete once the user authorized the payment. Wether the app really completed the purchase and delivers any benefit to the users, does not bother the App Store.

Of course the user could complain about the missing delivery of the purchased benefit, but how could this be handled?

When working with non-consumable IAPs the user could simple restore the previous purchase, but this is not possible with consumable IAPs, is it?

Without being able to restore the purchase form the App Store the only solution would be to store the receipt locally and offer the users the option to validate it later. Is this the "correct" solution or is there another way to handle this?

Upvotes: 2

Views: 549

Answers (1)

Paulw11
Paulw11

Reputation: 115051

Your sequence is incorrect at point 3.

Your app receives the updated transaction and then initiates whatever logic is required to validate and persist the purchase. Once your app has done this, it completes the transaction on the payment queue. At that point the purchase is complete from tye App Store point of view.

If your server is down and you are unable to validate the receipt, you should provide some form of error to the user and perhaps re-try the validation.

The transaction will be held in a pending state and will be re-presented to your payment queue observer when your app is next launched. This is why on of the first things your app should do on launch is register a payment queue observer object.

When you are finally able to complete the receipt validation and persist the purchase you complete the transaction on the payment queue.

Upvotes: 3

Related Questions