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

Question Google Play IAPs not restoring: Error. You already own this item

Discussion in 'Unity IAP' started by Toastbyte, Dec 1, 2021.

  1. Toastbyte

    Toastbyte

    Joined:
    Sep 1, 2016
    Posts:
    51
    Hello,

    I have implemented unity's codeless IAP into my android project by following all the steps in the documentation.

    However, after successfully purchasing a non-consumable and then reinstalling the app on my test device, the in-app purchases are not restored. Then, when I tap on one of the previously purchased non-consumable IAPs, this error message from Google Play appears:

    Screenshot_20211201-101036_Google Play Store.jpg

    I have already tried manually checking for receipts from the product ID, by calling the following function every time I open the in-game store page, but it doesn't work:

    Code (CSharp):
    1. IStoreController m_StoreController;
    2.  
    3. public void CheckIfPurchasedIAPs()
    4.     {
    5.         if (m_StoreController != null)
    6.         {
    7.             // Fetch the currency Product reference from Unity Purchasing
    8.             Product product_1= m_StoreController.products.WithID("id_p1");
    9.  
    10.             //check if the purchase was made, but is not restored in the game
    11.             if (product_1 != null && product_1.hasReceipt && !bought_product_1)
    12.             {
    13.                 //code for rewarding the non-consumable again
    14.             }
    15.         }
    16.     }

    Any ideas why Unity's IAP is not automatically recognizing the purchases made in the past and why manually checking for receipts is not working?

    EDIT:
    Here is the android logcat information at the point where I click on the already purchased non-consumable. It seems to just fail without giving any reason.
    upload_2021-12-1_10-40-17.png
     
    Last edited: Dec 1, 2021
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. Toastbyte

    Toastbyte

    Joined:
    Sep 1, 2016
    Posts:
    51
    Thank you for your reply.
    I am using just codeless IAP buttons at the moment. Isn't it sufficient?
    Would I need to add an IAP Listener on top to restore Google Play purchases? Before I start rewriting my whole project to use Scripted IAP, I would like to find a quick fix to at least make this work for now.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, you would need to add the IAP Listener (menu Window/Unity IAP/Create IAP Listener) to handle all events during IAP initialization, not just restore. But without receipt validation, your IAP purchases are open to hacking. And without support for Google deferred purchases, you'll miss out on potential purchases by users who want to use this payment type. This is where the user can make a purchase in-game, but has 3 days to pay for it at a Google-approved physical location. With Codeless, the user would be awarded the product immediately, before they actually pay. We plan to address these issues with Codeless IAP in Q1-Q2 of next year. https://docs.unity3d.com/Manual/UnityIAPCodelessIAP.html
     
  5. Toastbyte

    Toastbyte

    Joined:
    Sep 1, 2016
    Posts:
    51
    Thank you for your help and making this clear. Looking forward to the coming updates in codeless IAP.