Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Purchase with IAP Button gives Errors

Discussion in 'Scripting' started by Exarpo, Sep 6, 2020.

  1. Exarpo

    Exarpo

    Joined:
    Nov 25, 2019
    Posts:
    51
    I implemented a IAP Button using codeless IAP. When I click it, it correctly shows the window where you press either Buy or Cancel, cancel works fine and it triggers the onPurchaseFailedEvent. When I press Buy tho, it gives me this error:
    InvalidOperationException: Collection was modified; enumeration operation may not execute.
    Then, when I press it again, it gives me a completely different error:
    Purchase not correctly processed for product "MyProductName". Add an active IAPButton to process this purchase, or add an IAPListener to receive any unhandled purchase events.
    What can have gone wrong?
    EDIT: Also when I exported it to my phone to try it, it triggered the onPurchaseFailedEvent immediately without asking if I want to buy or close.
     
    Last edited: Sep 6, 2020
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    This will give you good results if you google.

    As for the other issues, it might be easiest to just attach the debugger to the phone and step through the code in question. If you prefer you can also sprinkle in lots of Debug.Log() statements, then use
    adb logcat
    to see what is happening in your code.
     
  3. Exarpo

    Exarpo

    Joined:
    Nov 25, 2019
    Posts:
    51
    I think both of the errors are something with the IAP sevice which I didn't write myslef but imported. My code that is suppsoed to run before and after the purchase works fine, the IAP itself struggles...