4

I'm using the receipt to validate a purchase after I get the SKPaymentTransactionStatePurchased notification, and among other things get the expiration date for the subscription the user just purchased.

To properly identify the transaction that just occurred in the receipt, I'm matching it by the transaction.transactionIdentifier and transaction_id. The problem I'm encountering is that the transaction identifiers never match up.

I've been able to identify the correct transaction in the receipt by manually inspecting the purchase_date and product_id, but the transaction_id completely differs from the Transaction.

I've also looked at transaction.originalTransaction.transactionIdentifier and original_transaction_id, but none of these four values seem to match up at any point.

What is going on here? Anyone had similar issues when testing in sandbox? The documentation clearly states that the transaction_id should match the transactionIdentifier property of the transaction. Could this be a bug?

Edit 1: Here's the different transaction identifiers for a single purchase of a subscription (that had previously expired)

transaction.transactionIdentifier = 1000000325087359
transaction.originalTransaction.transactionIdentifier = 1000000297785006
transaction_id = 1000000325087377
original_transaction_id = 1000000297785006

It seems as though the original transaction identifiers match up (why would they, it's a new purchase?), but the two others do not. Where do they come from and what do they match? I don't understand the relationship between the two and their significance.

Aleksander
  • 2,735
  • 5
  • 34
  • 57
  • I encount the same problem:https://stackoverflow.com/questions/68165228/why-could-not-find-transaction-record-on-the-server-side-in-apple-app-purchase – Dolphin Jun 28 '21 at 16:48

1 Answers1

0

The documentation for SKPaymentTransaction.transactionIdentifier notes:

This value has the same format as the transaction’s transaction_id in the receipt; however, the values may not be the same.

And the documentation for transaction_id notes:

This value has the same format as the transaction’s transactionIdentifier property; however, the values may not be the same.

You can use this value to:

• Manage subscribers in your account database. Store the transaction_id, original_transaction_id, and product_id for each transaction, as a best practice to store transaction records for each customer. App Store generates a new value for transaction_id every time the subscription automatically renews or is restored on a new device.

• Differentiate a purchase transaction from a restore or a renewal transaction. In a purchase transaction, the transaction_id always matches the original_transaction_id. For subscriptions, it indicates the first subscription purchase. For a restore or renewal, the transaction_id does not match the original_transaction_id. If a user restores or renews the same purchase multiple times, each restore or renewal has a different transaction_id.

I'll also note that the Receipt Validation Programming Guide (from the Documentation Archive) states under Transaction Identifier:

This value corresponds to the transaction’s transactionIdentifier property.

It's not clear to me in what scenarios the two fields are or are not the same except in the documented scenarios.

Jordan H
  • 52,571
  • 37
  • 201
  • 351
  • your answer help me a lot but I just wonder if the transaction id did not match in the subscribe, how to identify the transaction? how to match the transaction on the server side in retore workflow?@Jordan H – Dolphin Jun 28 '21 at 16:47