IAP ProcessPurchase called on startup?

For some reason ProcessPayment being called on start. Basically when I purchase an item, quit the game and open it again, it attempts to process the same item that I had just purchased. View the stack trace in the image. The error however is because the payment processing happens before all managers are started.

Why is ProcessPayment called on start?

ProcessPurchase is called after initialization as long as the purchase transaction is not marked as finished in Unity IAP internally. If you have an exception thrown within ProcessPurchase and did not return “PurchaseProcessingResult.Complete” at the end of it, it will be called again and again.

If you had an error in your code previously which has been fixed later, you might want to delete all Unity IAP transactions in the editor between testing stages. Call “UnityEngine.Purchasing.UnityPurchasing.ClearTransactionLog();” at runtime to do this.

Also, ProcessPurchase is called for restoring transactions on Android the first time you launch the app.

2 Likes

Yep, the problem was that I was returning .Pending. Switched to .Complete and it worked!
Thank you

This thread is now closed. Feel free to reach out via a new thread if you encounter further issues.
Thanks!

1 Like