Search Unity

[Solved] Previously purchased NonConsumables are consumed(!!) during Unity Purchasing initialization

Discussion in 'Unity IAP' started by CanisLupus, Feb 8, 2018.

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

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hi,

    On Google Play, since some time ago, there's no distinction between a consumable and a non-consumable. Using Unity Purchasing we call AddProduct for all our IAPs during runtime as ProductType.NonConsumable: one to unlock the full game and several others to unlock each DLC pack.

    The game itself knows the ID of the IAP that unlocks the full game, so we first initialize the Unity Purchasing system with just that IAP and detect if the player has the full game. On the other hand, the IDs for valid DLC packs are only known after contacting our servers, so it takes time. When we finally get them, we re-initialize the Unity Purchasing system with every product (full game unlock and all DLCs).

    Now, imagine we purchase the full game and one DLC pack and then the app data is cleared (or the player changes phone and loses previous data). The game must contact the store again. However, something is acting up, because when we initialize Unity Purchasing after calling AddProduct only for the full game unlock IAP (i.e. before we have the valid DLC IDs from our servers), the purchase of the DLC pack (which wasn't added as a product) is suddenly consumed, as seen in the logs:

    This is happening on Unity 2017.3.1f1, UnityIAP 1.15.0, on both Android 8.0 and 6.0. These are test purchases, as we haven't dared push this to the public yet, seeing that purchases will essentially be lost.

    Can anyone help or explain this? Perhaps @nicholasr? Help would be greatly appreciated! We can also send a bug report, but a test project would require a test application on Google Play and testing accounts.

    Cheers!
    Daniel Lobo
     
    Last edited: Feb 9, 2018
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you elaborate what a DLC pack is?
     
  3. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Regarding the purchasing system? Just a simple NonConsumable IAP.

    The full game unlock IAP is "com.somecompany.somegame.fullgame"
    The example pack IAP I gave above is "com.somecompany.somegame.dlc.pack1" but there are others.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  5. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    No, it's just a single IAP/product/item. :) It's called a pack because it contains several music tracks (it's a music game), but each pack is a single purchase.

    Yes, after adding "fullgame" to the builder using AddProduct, we call UnityPurchasing.Initialize. At that point, if the user has purchases of OTHER NonConsumables (any packs), they are immediately consumed without warning (so the purchase is lost).

    Thanks for mentioning FetchAdditionalProducts. We didn't know about it. I will try that tomorrow and see if it solves this problem.

    Would you say that initializing more than once is undesirable and could result in strange behaviour? This still feels like a bug. The NonConsumables are being... well... consumed!
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @CanisLupus Yes, we recommend to Initialize once at the beginning of the game, and implement it as a singleton.
     
  7. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    It is a singleton already. We'll try that today. :)

    Will anyone at Unity look into this? If this happens to non-test purchases my guess is that purchases are being lost all over the world. Even if there's no double initialization, if a game stops adding a NonConsumable product to the IAP system in an update, the user will lose that purchase on startup without notice.
     
  8. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    I was thinking... FetchAdditionalProducts won't solve our problem. The problem is that the first initialization consumes other NonConsumable purchases (those that were not added as products), so the problem happens before we can even call FetchAdditionalProducts.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please open a support ticket on the Support tab of your Analytics Dashboard at https://analytics.cloud.unity3d.com/support and provide a minimal test project (if you can) that reproduces the issue, and we can look further. Your purchase script may suffice also.
     
  10. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hey, I've spent a good while creating a repro project, but you'll still need a Google Play app and IAPs to test it. I've filled the ticket but completely forgot to add a link to the test project so here it is, attached. :)

    I've ALSO submitted the exact same bug report using the standard Unity Bug Reporter.

    This is a really important (and urgent) issue for us. As it stands there's no way to guarantee that our users don't lose their NonConsumable purchases (apart from waiting for all available purchases to be acquired from our servers, which may fail due to server issues, case in which the game can't even check if the user has the full game or not because the IAP system was not initialized).

    Please keep me posted if you are able to. Thanks for looking into this!

    Daniel
     

    Attached Files:

  11. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    This issue was handled in the support ticket, but I wanted to resolve the forum thread in case anyone comes across it:

    The underlying issue is that in the current version of Unity IAP (1.16), when Unity IAP encounters a product ID that is not mentioned in the Configuration Builder during initialization, it will automatically consume that transaction on Google Play. This will likely be addressed in a future version, where instead we do nothing with product IDs that are not registered.

    In the meantime, we recommend including all the product IDs during initialization.
     
Thread Status:
Not open for further replies.