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

Error when user cancels the purchase

Discussion in 'Unity IAP' started by alexm_scp, Nov 19, 2020.

  1. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi!
    Working with the latest version 2.2.1in Android devices I've found this error when user just cancels the purchase:
    ArgumentNullException: Value cannot be null.
    Parameter name: key
    at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <a77b706cff6d42519dc3f45262adbd0a>:0
    at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in <a77b706cff6d42519dc3f45262adbd0a>:0
    at UnityEngine.Purchasing.ProductCollection.WithStoreSpecificID (System.String id) [0x00002] in <5ecb2210403e4c40ac7ea62abef13f21>:0
    at UnityEngine.Purchasing.PurchasingManager.OnPurchaseFailed (UnityEngine.Purchasing.Extension.PurchaseFailureDescription description) [0x0000c] in <5ecb2210403e4c40ac7ea62abef13f21>:0
    at UnityEngine.Purchasing.ScriptingStoreCallback+<>c__DisplayClass10_0.<OnPurchaseFailed>b__0 () [0x00000] in <077bf92f53a44ef88bbed88506d6de01>:0
    at UnityEngine.Purchasing.Extension.UnityUtil.Update () [0x0007f] in <077bf92f53a44ef88bbed88506d6de01>:0 ​

    And the OnPurchaseFailed function is not being triggered so I have an error which I can't handle
    What can I do?
    Thanks
     
  2. IndexOutOfRangeException

    IndexOutOfRangeException

    Joined:
    Apr 16, 2015
    Posts:
    6
    I'm having the same problem.
     
  3. max427857

    max427857

    Joined:
    Sep 9, 2020
    Posts:
    8
    I think it's better to wait for version 2.2.2. Currently stable version 2.1.1 (it's true there are some bugs, but in rare cases)
     
    nicholasr likes this.
  4. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Hello!

    Please update your Asset Store Package to 2.2.2 for a fix for this. Also be sure that your Package Manager package is at 2.2.1.
     
  5. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Thanks John,
    I've already tried, It seems it works quite fine but there are some errors. For example: sometime when user cancels the purchase and tries to buy it again the ProcessPurchase and OnPurchaseFailed functions are triggered both at the same time.
    One important bug: when there is an error on initialising the service (UnityPurchasing.Initialize) the OnInitializeFailed function is never called so I can't handle the error.
     
  6. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @alexm_scp

    Regarding the
    ProcessPurchase
    with
    OnPurchaseFailed
    triggering at the same time, we'll investigate. Does this happen 100% of the time? on which platforms?

    Can you please elaborate on this error in
    UnityPurchasing.Initialize
    ? We'd like to fix it as soon as possible. At the moment we're aware of an error where the products retrieved is not providing the receipts for Google Play. Is this what you're experiencing, or is it something else altogether?
     
  7. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi John,

    The ProcessPurchase with the OnPurchaseFailed at the same time I saw it few times, maybe it was related with some pending purchase or similar.
    But the bug which made me move to downgrade to version 2.1.1 is the other bug. I have some issues when player disconnects his Google Play account and enters to game. In that case in v. 2.2.2 the plugin throws an error and it doesn't trigger the OnInitializeFailed function. I'm pretty sure if we try to Initialize the plugin without internet connection this error will appear as well.
    So the point here is when the UnityPurchasing.Initialize fails the callback is not called and I can't handle the error.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you returning Pending from ProcessPurchase?
     
  9. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi Jeff,

    I'm not able to use ProcessPurchase, the UnityPurchasing.Initialize fails and I don't receive the callback on OnInitializeFailed.
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    That would be a separate issue, this thread is discussing cancelled purchases. But your issue is being looked at.
     
  11. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    In that case the problem was solved with the new version but I didn't check again the other issue about the ProcessPurchase and the OnPurchaseFailed triggered at the same time.