- Home /
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;
}
Answer by YasinJavaid_ · Oct 15, 2019 at 04:40 AM
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.
Answer by hawkzey · May 18, 2017 at 12:37 AM
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.
I have implemented IAP yesterday and its working fine. But i wanted to check if the purchases the user make are being restored and as I am working on Google Play there is no restore button to implement, the restoration should be automatic. The thing is i haven't used Google Sign In and when I clear the data of the app or delete and reinstall the app from play store, the coins I bought with IAP just wipes out and I just have to buy new coins. (Note: I use Player Prefs to save the coins) I was wondering if i need to upload the save game to Google Play or do i have to use Google Sign In. Can you please help ?
P.S. I am on Internal Testing of the app and have tested the IAP only from a Licence Account.
Answer by hexagonius · Dec 13, 2016 at 07:22 AM
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
ive already read that.. what I am asking is restoring IAP in google play store.. on the manual page it only restore IAP in iOS.. so I am puzzled if it is automatically restored in GOOGLE PLAY without the code provided in the manual page.