[Solved] IAP purchase process being being called twice

Hi,

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:

Here’s my details:

Platform: iOS
Unity Version: 2017.1.2.f1
Unity IAP Version: 1.14.0

\\is there any known issue with Unity related to this? Is there any workaround I can try or something I may be doing wrong?

Any help would be much appreciated, thanks!

So this is in TestFlight? What iOS version?

Thanks for returning on this.

Tested this issue on iOS 11.0.2 and iOS 11.0.3, directly on the device (both have the same issue).

I had an older build on TestFlight, but unfortunately it expired recently. Otherwise I would rund it to see if it’s also affected.

Look forward to your feedback.

Thanks!

Can you post your purchase script here? Otherwise, you could open a support ticket, go to the Support tab in the Analytics Dashboard.

As I believe I mentioned, I’m using codeless IAP. Please find a screenshot below:

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!

3264771–251913–ShopItem.cs (4.55 KB)

Sorry, I missed that you are using Codeless IAP. Can you describe a bit more what you see on the device when this happens?

No worries. Again, thanks for returning.

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…

Thanks!

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! :slight_smile:

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?

Thank you so much for the precious help!!!

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

Ok, I was trying to stick with Codeless IAP but you may be right. Many thanks for the feedback!

@tugcoder

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.

https://discussions.unity.com/t/642578/4
https://discussions.unity.com/t/679810/2

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.