Find restored transaction Id in receipt

I have a query regarding IAPs and the process around restoring them. Pre iOS 7 the traction Id was used as the unique transaction identifier and therefore when you restored a purchase you would get a new transaction id under the same receipt. However post iOS 7 this is no longer the case and one approach is to compare receipt and purchase dates (as per this Apple forum post):


“The transaction_id in post iOS6 receipts is now the same as original_transaction_id. There is no separate field for the transactionIdentifier for the latest transaction, just for each individual IAP - and they all reflect the original purchase transaction. This means transaction_id can no longer be used to identify a copied receipt nor can it be used to tell whether the user has restored a transaction or repurchased an item for free. What you can do is detect the value of "receipt_creation_date" aka "creation_date" and compare that to the value for "original_purchase_date". If they are within a few seconds of each other then the purchase is a new paid purchase not a restore and not a repurchase-for-free. Also, if "creation_date" is close to [[NSDate alloc] init] then the receipt is not copied - you have to get the NSDate format correct.”


However this feels like a very brittle solution. Is there any other way that a developer can determine whether the transaction in the receipt returned is a new purchase, a restoration or a repurchase for each transaction, now we no longer get a unique transaction id based on the latest transaction only the original id?

if all you have is the receipt, my quote stands. If you have the transaction object there are lots of things you can do. Also, you can keep a database of transaction_identifiers and use that to flag restores and repurchases.

Thanks PBK - this does look like the only solution that will work at this point in time 🙂

Find restored transaction Id in receipt
 
 
Q