Search Unity

[Wrong behavior] Already recorded transaction

Discussion in 'Unity IAP' started by AbgaryanFX, Dec 6, 2018.

  1. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    I have two way to buy same product (non-consumable). When I fully test first one and switch to second I get "Already recorded transaction" when I try to test purchase same item.
    Question: If the item is already purchased isn't it correct to fire purchase success event rather than throwing a useless exception?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I don't quite follow. You should get an exception when trying to purchase the same non-consumable product again. You should design your app so you don't allow the user to purchase a non-consumable a second time.
     
  3. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    Ok.
    Question II: Where I can find info about handling IAP on android, for example when app is uninstalled and installed again, how to recover user's purchases ?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Non-consumable purchases will be automatically restored, you can expect to get a ProcessPurchase callback. For other purchases, you can save the purchase history in PlayerPrefs.
     
  5. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Both. You can check item.hasReceipt during initialization. There is an example IAP project here: https://forum.unity.com/threads/sample-iap-project.529555/

    Code (CSharp):
    1. m_StoreController = controller;
    2.         m_StoreExtensionProvider = extensions;
    3.         foreach (var item in controller.products.all)
    4.         { ....