Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[Wrong behavior] Already recorded transaction

Discussion in 'Unity IAP' started by Artyom-Abgaryan, Dec 6, 2018.

  1. Artyom-Abgaryan

    Artyom-Abgaryan

    Joined:
    Jan 9, 2010
    Posts:
    147
    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    2,822
    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. Artyom-Abgaryan

    Artyom-Abgaryan

    Joined:
    Jan 9, 2010
    Posts:
    147
    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    2,822
    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. Artyom-Abgaryan

    Artyom-Abgaryan

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

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    2,822
    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.         { ....