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

Feedback Handling Google play NonConsumables

Discussion in 'Android' started by slaga, Apr 27, 2021.

  1. slaga

    slaga

    Joined:
    Dec 3, 2018
    Posts:
    142
    To my understanding everytime a game launches it checks for ProcessPurchase function right? and depending on the function under the non consumable if it finds it purchased it passes the function to the game. Now so far so good. i have set up some non consumables i want and i can buy them just fine use them etc with no issues. Now inside that function i also save the data each time a purchase is made and then on my other scripts i just check a variable if == 1 to open said item. What im having trouble with is making sure if the non consumable is refunded to not load that variable and lock the prosuct again. how do you guys handle something like that?

    edit: My main concern is not being able to block the content in case of a refund or return, i did lurk around a bit and read a few threads but it seems its an ambiguous subject. what i would like help with is detecting if that product has a receipt and if it does to give the content to the player, set the value to 1, if not set the value back to 0 on my save manager and thats all!!
     
    Last edited: Apr 27, 2021
  2. slaga

    slaga

    Joined:
    Dec 3, 2018
    Posts:
    142
    managed to make it! seems to be working ok!

    Code (CSharp):
    1.  Product procuct= m_StoreController.products.WithID(// your product id here //);
    2.  
    3.         if (product!= null && product.hasReceipt)
    4.         {
    5.             Debug.Log("enabled");
    6.             /// do what you need here!
    7.         }
    8.         else
    9.         {
    10.             Debug.Log("disabled");
    11.            /// do what you need also!
    12.          }
    13.         }
    this is placed inside OnInitialized !!