@oscaretu does it mean that original_transaction_id is globally unique and we can use it to identify user? I mean Apple documentation says original_transaction_id / transaction_id are unique to particular user. But can 2 different users have transaction with the same original_transaction_id / transaction_id?
In our app and backend we do exactly what you have described. But we've faced some issue. So,
User purchases subscription in the App
The App sends request to the backend with transaction_id and our internal user_id
Backend creates record in database to link transaction_id with user_id.
Apple sends INITIAL_BUY notification to our backend
Backend process verifyReceipt and based on the response data creates subscription record in our database. Because we have transaction_id linked with the user_id we know that this subscription belongs to this particular user.
However, we have faced an issue that Apple Notification comes to the backend quicker than App sends request to the backend to link transaction_id with the user_id. So, processing INITIAL_BUY notification fails, as we cannot fetch user_id by transaction_id and save subscription to our database.
We've been thinking to save subscription without user_id when processing INITIAL_BUY notification and then link subscription to the user_id afterwards, when app sends transaction_id and user_id to the backend. But how do we know which subscription to link with the user? How to identify correct subscription? We don't want the case that one user will "steal" some other user's subscription.