2

I've been struggling with this for some days now. I hope I get it now, but I wanted to check it with you.

For every transaction there is a SKPaymentTransaction. In a regular purchase, the property Original Transaction is empty. In a restore or auto renewal, Original transaction is the original transaction SKPaymentTransaction.

The tricky part in my opinion is the receipt received. So every transaction in the receipt contains a transaction_id and a original_transaction_id. In a one time purchase they are the same, in a subscription, the original_transaction_id is the transaction_id of the first transaction the user subscribed.

So my first question: If I want to check the validity of a purchase in the receipt -> The transactionID of the SKPayment transaction appears ONLY in the receipt, if it is not a restore or renewal. Otherwise the SKPaymentTransaction transactionID is NOT in the receipt. But since in these cases the SKPaymentTransaction has a property originalTransaction, originalTransaction.transactionID appears in the receipt. Correct?

And now the thing I have been struggling with, 2nd question: So the originalTransaction property of the SKPaymentTransaction has not necessarily anything to do with the original_transaction_id in the receipt, correct? I mean for a subscription with several renewals - If I restore them I get a SKPaymentTransaction with a transaction ID, which isn't in the receipt. Then I take instead the originalTransaction.transactionID of this SKPaymentTransaction and look for it in the receipt, but NOT in the original_transaction_id field but in the transaction_id field of the receipt, correct?

I hope I get it now..I really think the documentation is rather confusing here from Apple..

MichiZH
  • 5,587
  • 12
  • 41
  • 81

2 Answers2

0

Restoring the transactions on your device will generate unique transaction_id's. So the original_transaction_id will not be found after this if you do it. The same happens on different devices, e.g. iPad, iPhone. the web_order_line_item_id will not change for these transactions if you need a stable identifier.

Hitch22
  • 365
  • 1
  • 9
-1

Yes, in your SKPaymentTransaction there is a property originalTransaction. You can find your original_transaction_id in the receipt. However it is not a good way to validate receipt, because it should be done using the server to avoid man in the middle attacks. I would recommend you validating receipt through the server as Apple recommends. There are a few of ready-to-go solutions, like ours - Apphud or RevenueCat.

Also I would recommend you reading articles about what is receipt validation and why it's needed: https://blog.apphud.com/receipt-validation/

apphud
  • 625
  • 4
  • 8