Since recently (don’t know exactly when) I noticed that IAP purchases are being called twice when the IAP button is tapped (I’m using codeless API) I’m testing on an iOS build, not sure if it also affects Android. Curious that I found this thread with exactly the same issue for Android, but apparently solved:
Maybe it’s unneeded but in case it helps, please also find attached the script which contains the functions
public void CashPurchase (Product product) and
public void CashPurchaseFailed (Product product, PurchaseFailureReason failure)
Which are called by the codeless IAP button
On Purchase Complete and
On Purchase Failed
,respectively.
Thanks!
Sure, when I tap an IAP item (button), I (the player) get the IAP confirmation screen. If I tap “Cancel” or “Buy” it will close this window and open a new (equal) one. If tapped “Buy” it will say that the item was already purchased an it will be restored.
Please find below a screenshot below in case it helps. It’s in Portuguese though…
A co-worker spotted the likely issue. You look to be calling the purchase method twice, once in the IAPButton and another time in the button OnClick callback. You should disable the OnClick callback of the button.
Thank you very much!! Yes, disabling the OnClick callback did solve the problem!
But…does it make any sense? The method being called there (which I named “DisableButton” and which by the way I would like to keep if I could) is not the purchase method. It is just a method I wrote to sort of dim the IAP button (place a semi transparent image on top of it with the text “…”) while the purchase , which sometimes takes a few seconds, is being processed. It does that and disables the button until the process is completed (or canceled), so as to signal the player that the tap produced some effect and to prevent her or him from clicking it again.
Since it’s not the purchase method, does it make sense? I will scratch my head a bit to find an alternative, but would you be able to suggest another way to call this method, still using codeless IAP?
If you want button behavior that is not offered via Codeless IAP, you can certainly implement IAP yourself in code or modify our existing code (not generally recommended as it makes updating difficult) Unity IAP - Unity Learn
Yeah, your code doesn’t suggest any reason why the purchase dialog would show up twice.
I noticed that you are in Sandbox mode on iOS (which is recommended). We have gotten several reports of multiple popup dialogs while doing Sandbox testing. And this includes reports of using native methods outside of Unity IAP.
So far, this has always been limited to Sandbox and has never caused any issues in production. You could consider reporting this issue to Apple’s developer forums and see if there is a workaround.
Otherwise, I think it’s safe to continue using Codeless IAP and please let us know if you run into any of these issues in production.