I'm currently using UnityIAP to make purchases and PlayFab for receipt validation. The first time the player makes the purchase everything works fine.
If purchase restoration is triggered, Unity IAP tries to restore the purchase, and I send the receipt to playfab for validation.
Validation fails, because the receipt has already been used during the first validation.
Is there a way to fix this?
Thanks in advance!
Answer by Brendan · Oct 12, 2016 at 01:30 AM
[Edit: Updated with the correct Store Kit API reference]
We track on receipt usage, to ensure that players can't cheat and get the item they paid for multiple times. Otherwise, a hacked client could just send the same receipt over and over again, to amass tons of VC, for example.
To restore previous purchases (when a player signs into a new account due to a lost phone, etc.) on iOS, you need to use a Restore Receipt (https://developer.apple.com/reference/storekit/skpaymentqueue/1506123-restorecompletedtransactions). This is a fresh receipt, generated by the iTunes service, which can be used to grant the items to the player.
Google does not provide a similar "restore" style receipt currently. On their platform, you would need to get the list of items the player purchased (https://developer.android.com/google/play/billing/billing_integrate.html - check the "Querying for purchased items" section) and grant them to the player again in Cloud Script (after checking to make sure the player doesn't already have the items).
Of course, ideally, you'd just get them back to their original account by having a common login method, like Facebook, Twitch, etc. :)
Answer by andreswx@gmail.com · Oct 12, 2016 at 02:03 PM
Thanks Brendan! We do have a common login method, but we wanted to check other options too.