In-app transaction recovery

The idea is, rain or shine, wet or fine, the user should get what he paid for everything.

From Apple:

  Store Kit provides built-in functionality to restore transactions for non-consumable products, auto-renewable subscriptions and free subscriptions

The Apple Store Kit has good built-in tools for these transactions. I want to focus on other types (in particular, consumed). One and only transaction information is the identifier and receipt information that we receive through the Store Kit after a successful purchase. Our application uses a server model for delivering products to it. But there are still many cases of loss of purchase data, for example, if the server goes down when a user makes a purchase through the App Store, so it is impossible to send a receipt to the server to complete the verification process.

Current workaround:

  • The server returns a list of product identifiers
  • The user selects one; The application saves its identifier on the device (via SQLite or Core Data). After that, the transaction process of the standard Apple Store goes.
  • If successful, the application saves the receipt data along with its identifier on the device and sends it to the server. If a failure or cancellation occurs, the identifier is immediately deleted from the device.
  • If the server response is OK, the application deletes the ID with the receipt data from the device. Otherwise, it will periodically send requests to the server until a successful response is reached.

But this approach still has leaks. For example, a user can remove an application from a device without waiting for the transaction to be delivered to the server, so there will be no evidence of its purchase at all.

Your suggestions?

+6
source share
1 answer

The basic rule is that you do not call finishTransaction: in the payment queue until you successfully deliver the content. This means that you are making a request to the verification and content servers, and they are returned with valid responses. Only after these correct answers do you call finishTransaction :. Please note that a bad purchase receipt is only valid not very good. You will get people trying to pluck goods - do not lose sleep over it, but do the correct check of checks.

As I understand it (from my non-expendable elements), until you call finishTransaction, the repository will continue to repeat it when the application is installed. For this reason, I don’t think you need your application to save the receipt on the device. However, for supplies, the server must store data if you want to restore it later. A nontrivial problem is the key to storing it.

By the way, your first line is absolutely correct and it is worth losing a dream.

+3
source

All Articles