How google play restore In App Purchases

I’m wondering how google play restore in app purchases (NON-CONSUMABLE) if I’am using “playerprefs” to save the state of the product as purchased.

Is it check on UnityEngine.Purchasing InitializePurchasing() if the product was already bought? If then, how is that go to set the playerprefs?

I’am using Unity IAP

 public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args){
            if (String.Equals(args.purchasedProduct.definition.id, pid_bundle_1, StringComparison.Ordinal)){
                       *PlayerPrefs.SetInt(pid_bundle_1, 1);
                       PlayerPrefs.SetInt("paid", 1);*
             }    
            return PurchaseProcessingResult.Complete;
        }

Hi i use following to restore my IAPs. now google and Unity IAP plugin provide automatic IAP restore but some how automatic restoration of IAPs don’t work always so i use this to manually restore my IAPs on button press.

 public void Resore()
 {
       
	if  (m_StoreController.products.WithID("com.your.iap.id.1").hasReceipt)
	{
	   // IAP success results. 
	}
	 if  (m_StoreController.products.WithID("com.your.iap.id.2").hasReceipt)
	{
	   // IAP success results. 
	}
	.
	.
	.
	.
	 if  (m_StoreController.products.WithID("com.your.iap.id.N").hasReceipt)
	{
	   // IAP success results. 
	}

this only works with non consumable and subscriptions.

You feel like you need to do something extra to perform the enabling of already purchased items but you don’t.

When the app is deleted or downloaded on a new phone, the IAP’s back end process will call the ProcessPurchase Function you have specified from the IStoreListener class on each item being restored(this is saved internally on each players google account). So what ever code was executed for when the player originally bought the item is executed again, there for re-enabling it.

this manual page explains how to set up IAP from the start

https://unity3d.com/de/learn/tutorials/topics/analytics/integrating-unity-iap-your-game