Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restoring In-App Purchase Transactions

The idea is whether rain or shine, wet or fine, user must get that he paid for all out.

From Apple:

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

For these transactions Apple Store Kit has good build-in tools. I want to focus on other types (consumable in particular). One and only transaction information is an identifier and a receipt data which we receiving by Store Kit after successful purchase. Our application uses server-side model to deliver products to it. But there still much cases of losing purchase data, such as if the server lay down while user is making purchase via App Store so its not possible to send receipt to server to complete verification process.

Current workaround is:

  1. Server returns a list of product identifiers
  2. User selects one; app saves its identifier on device (via SQLite or Core Data). Standart Apple Store transaction process goes right after that.
  3. In case of success application saves receipt data in conjunction with its identifier on device and send it to server. If there were failure or cancelation the identifier is immediatelly removed from device.
  4. If server's response is OK then app removes identifier with receipt data from device. Otherwise it will send requests to server periodically until successful response behaves.

But this approach still has leaks. For example, user can remove application from device not waiting for transaction delivering to server, so there will not any proof about his purchase at all.

Your suggestions?

like image 632
Lion Avatar asked Dec 18 '12 22:12

Lion


People also ask

What happens when you restore in-app purchases?

Restoring purchases is a mechanism by which your user can restore their in-app purchases, reactivating any content that had previously been purchased from the same store account (Apple, Google, or Amazon).

Is restoring purchases a refund?

"Restore Purchases" reinstates purchases that haven't been automatically restored, eg. if you are transferring data to a new device. It's not a way to refund your purchases.

How do I restore previous app purchases?

To restore your purchases:Open the drawer from the upper left corner of the screen and select Support. Select Purchases and Paid App from the menu. Tap on the menu option, located in the upper right-hand corner of the screen. Tap on Recover Paid App.


1 Answers

The fundamental rule is that you not call finishTransaction: on the payment queue until you have successfully delivered content. That means that you make the request to your verification and content servers and they come back with valid responses. Only after those proper responses do you call finishTransaction:. Note that bad purchase receipt is valid just not good. You will get people trying to ripoff goods - don't lose sleep over it but do put in proper receipt checking.

As I understand it (from my non-consumable items), as long as you do not call finishTransaction, the store will continue to retry it on your app installation. For that reason, I do not think you need your application to save the receipt on the device. However, for consumables, the server has to store the data if you want to be able to restore it later. A non-trivial problem is what key to store it under.

BTW, your first line is absolutely correct and worth losing sleep over.

like image 50
DrC Avatar answered Sep 23 '22 00:09

DrC