iOS - Can we get unique USER identifier for in-app purchases?

I have a game I’m working on that includes in-app purchases. There are some content creators who are getting royalties per purchase, rather than a flat fee, so I need to track downloads. I know I can ping my database when a purchase is successful, but unfortunately it looks like the Apple system calls a successful purchase whenever the user clicks the “restore purchases” options, which would ping my server with a “sale” that wasn’t really a sale.

Is there a way to keep track of the specific USER, so that when they restore purchases on a 2nd or new device I don’t end up tracking the sale as a new sale?

When you restore purchases (vs forcing them to ‘rebuy it for free’), you will get the restoreCompletedTransactions method called by iOS which enables you to distinct a sale from a restore.

for more informations, please check

Additionally both the original transaction as well as the restore transaction contain an SKPaymentTransaction object which has a unique identifier which you can lookup in your DB to verify if it is a sale or a restore -