Search Unity

When a transaction succeeds does InventoryManager.itemAdded event fire?

Discussion in 'Game Foundation' started by metiscoda, Aug 28, 2020.

  1. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    If I purchase an IAP transaction and it adds currency, does the InventoryManager.itemAdded event fire? What if the IAP transaction grants me an inventory item? Does that event fire?

    I seem to not get this firing for me when I expected it to.
     
  2. richj_unity

    richj_unity

    Unity Technologies

    Joined:
    Sep 23, 2019
    Posts:
    40
    If an IAP transaction adds currency, it will do so via the WalletManager, and that will invoke the WalletManager.balanceChanged event. The balanceChanged event will also happen when a currency is deducted, as with virtual transactions. If an inventory item is granted, that will invoke the InventoryManager.itemAdded event.

    Since a single virtual or IAP transaction could result in both inventory items and currencies, both events will be invoked, once for each currency or item affected. There's also a
    TransactionManager.transactionSucceeded event in case you just want one event for the whole transaction instead of every item/currency affected. It contains a TransactionResult that has info about how much and which currencies and items were added/removed.

    If you're still having trouble getting the events to fire, could you post the code you use for handling the events?
     
    erika_d, mingz-unity and saskenergy like this.