Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving / restoring auto-renewing receipts without duplicates

I'm developing an app with auto-renewing receipts, and saving them in the server, which is all working great, until the user restores their purchases - this causes duplicates.

The transaction_id field is different for the same receipt with every restore, and the original_transaction_id is obviously the same across every run of renewals, so I can't use that. The unique_identifier field is also the same (I don't understand how it's unique). I had been using the web_order_line_item_id field and it seemed fine, but I just tested this with a completely new account, and ended up with a duplicate, so that's useless too.

I am missing something really obviously here? There must be a field that is unique to every receipt, but doesn't change each time it is restored?

like image 836
Malcolm Christie Avatar asked Jul 11 '13 20:07

Malcolm Christie


1 Answers

Apparently original_transaction_id and purchase_date are the only two unique values that will not change after restoring purchases. You can also rely on latest_receipt_info -> web_order_line_item_id as it doesn’t change between restores (unlike latest_receipt_info -> transaction_id). By inspecting latest_receipt_info you can find out expiration_date of the subscription, which apparently apple believes should be enough for you.

like image 129
avdyushin Avatar answered Oct 20 '22 15:10

avdyushin