Search Unity

[Solved] IAP purchase process being being called twice

Discussion in 'Unity IAP' started by tugacoder, Oct 23, 2017.

Thread Status:
Not open for further replies.
  1. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    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:
    https://forum.unity.com/threads/sol...sspurchase-for-same-product-two-times.496265/

    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!
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,149
    So this is in TestFlight? What iOS version?
     
  3. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    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!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,149
    Can you post your purchase script here? Otherwise, you could open a support ticket, go to the Support tab in the Analytics Dashboard.
     
  5. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    As I believe I mentioned, I'm using codeless IAP. Please find a screenshot below:

    IAP screen.png
     
  6. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    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!
     

    Attached Files:

  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,149
    Sorry, I missed that you are using Codeless IAP. Can you describe a bit more what you see on the device when this happens?
     
  8. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    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!

    IMG_0772.png
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,149
    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.
     
  10. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    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?

    Thank you so much for the precious help!!!
     
    Last edited: Oct 24, 2017
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,149
  12. tugacoder

    tugacoder

    Joined:
    Nov 30, 2015
    Posts:
    11
    Ok, I was trying to stick with Codeless IAP but you may be right. Many thanks for the feedback!
     
    Last edited: Oct 25, 2017
  13. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,258
    @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://forum.unity.com/threads/clo...times-for-some-users-ios.435672/#post-2866151
    https://forum.unity.com/threads/clo...n-loop-and-slow-response.500132/#post-3255571

    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.
     
Thread Status:
Not open for further replies.