Search Unity

Question Restore Purchase button acts as the game was bought

Discussion in 'Unity IAP' started by ShinyOpal, Mar 28, 2023.

  1. ShinyOpal

    ShinyOpal

    Joined:
    Dec 17, 2022
    Posts:
    32
    My game has the Buy and Restore button and uses the Codeless IAP

    According to one of the players, he clicked the Restore button without first buying the game and the game behaved as if it was already bought. Could you confirm this is not the case ? Restore can work only if the game was previously bought, right ?
     
    Last edited: Mar 28, 2023
  2. ShinyOpal

    ShinyOpal

    Joined:
    Dec 17, 2022
    Posts:
    32
    Would this be the correct implementation of the event handler on the restore button ?

    Code (CSharp):
    1. public void OnTransactionsRestored(bool param1, string param2)
    2.     {
    3.         if (param1)
    4.         {
    5.             PurchaseCompleteOrRestored();
    6.         }
    7.     }
     
  3. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    235
    Hello ShinyOpal,
    The OnTransactionsRestored callback only serves to notify if the restore transaction operation was successful or not, but it doesn't indicate whether any product was restored. This is more a confirmation from the store that it has received your request and that it will reply to it.

    Once it's successful, the store will then send the transactions to restore to our transaction listener and these will go through your ProcessPurchase where you can handle them. If there's nothing to restore, this can still be successful, but you won't see any products in the ProcessPurchase.
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,266
    Just to be explicitly clear on this - as Yannick_D has said, you should not call any purchase/restore/unlock product code in the OnTransactionsRestored callback whatsoever. You can display a "Restore request finished" message to the user based on "bool param1", but do not handle anything with your products in there.
     
    Laurie-Unity and Yannick_D like this.