javaandroidgoogle-apigoogle-playandengine

Android in-app shop: How to restore purchases


I'm developing an Android game that contains a shop where the player can buy virtual clothes for the main character like t-shirts, hats, trousers etc. These articles can be bought with coins which the player can buy as an in-app-purchase (unmanaged).

Example: Assuming that the player buys 100 coins for 1.99$ and then buys 4 different t-shirts using these coins: Now 4 t-shirts are unlocked (stored locally) and the 100 coins are spent. But what if the player buys a new device or wants to play the game on another device? Then the 4 t-shirts cannot be restored, right?

Is there a way to store such purchases to a google account? And what is the best way to restore such in-app purchases? I've read about androids AccountManager and cloud services from google, but it would be nice to achieve what I want using the In-app Billing API from google?


Solution

  • there are 2 types of products for in-app purchases Managed and Un-managed a managed product google keeps track of and you can query what the user has purchased while unmanaged product is not held by google

    http://developer.android.com/google/play/billing/api.html#producttypes

    what you want is a managed product probably and to get all the products that the user has bought all you have to do is query their purchases. Once a managed product if bought by the user it cannot be bought again unless the product if "consumed"