ProcessPurchase is being called every time I load my app.
This started when I cancelled the IAP through Google’s merchant account page (which I did so that I could re-test buying that specific non-consumable product).
I’m using GameSparks to validate receipts, and it returns an error each time as the receipt has already been used. I then show a message to the player telling them their purchase has failed, which obviously doesn’t make sense in this case.
I’m also aware that if I delete the app, ProcessPurchase is called automatically to restore purchases (Unity - Manual: Restoring Transactions) - I can see the same problem happening here - the receipt will be checked and shown to be a duplicate.
I tried using
Directory.Delete(Path.Combine (Path.Combine (Application.persistentDataPath, "Unity"), "UnityPurchasing"), true);
as shown in [Solved] Is it possible to delete an IAP non-consumable product? - Unity Services - Unity Discussions but it hasn’t made a difference.
My questions are:
- Why is ProcessPurchase being called after I’ve cancelled an IAP and how do I stop it?
- Assuming ProcessPurchase is meant to be called when an IAP is cancelled/if it’s called when an app is reinstalled, is there a way to check (probably inside the ProcessPurchase method) whether ProcessPurchase is being called due to an actual purchase?