Im implementing codeless IAP in my app, but I have some questions. I have 5 consumable and one non-consumable, so let's say player bought 100 gold and remove ads and deleted app or changed his/her phone. After reinstalling the game are these purchases restoring or they have to buy again. How can I save the purchase history. My purchase script is below. Code (CSharp): if(product != null) { switch (product.definition.id) { case "Gold.50": PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 50); GoldText.text = PlayerPrefs.GetInt("Gold").ToString(); Debug.Log("Completed"); break; case "Gold.100": PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 100); GoldText.text = PlayerPrefs.GetInt("Gold").ToString(); Debug.Log("Completed"); break; case "Gold.250": PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 250); GoldText.text = PlayerPrefs.GetInt("Gold").ToString(); Debug.Log("Completed"); break; case "Gold.500": PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 500); GoldText.text = PlayerPrefs.GetInt("Gold").ToString(); Debug.Log("Completed"); break; case "Gold.1000": PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 1000); GoldText.text = PlayerPrefs.GetInt("Gold").ToString(); Debug.Log("Completed"); break; case "removeads": break; default: Debug.Log("Failed"); break; } }
I am sure you know what I mean, if you talking about purchased in app. Otherwise, how you would deal with in game purchases itself? Basically you need store relevant information on some server. If you not familiar with a subject, I suggest search and read about it.
I did research before writing here. but I could not find what I wanted so I opened the subject here. if I had found what I want, I wouldn't open the subject here. I just want to save the purchase history, so that when the player reinstall the game, can get back what he/she bought. The question was so simple. what I need to use to save the purchase history
As I said, you need use some form of database on the server. This is in brief as it can be, to give the idea about searching for information. From what you describe you don't want save on local device history. Because database subject is beyond your current expertise, that is why I suggested you to read about this. Look about clouds, database storing data, Unity and you will find tons of subjects. I am not going into what services are available, as this is ocean topic by its own. You could use web request from Unity to PhP to save on the server. But this may be too complex at this stage for you. Not that can not be learned of course. Depends what you really need.
A good solution, as mentioned, is to use a web service API to write to a database on the server. So as a first step you would need a public server, like on AWS or Azure or Google Cloud. You can develop on your own computer, but you need it to be running a local web server and a local database like MySQL.