How to implement currency with Google's In-app Billing API Version 3

Like the title says, how should I implement a currency system with Google’s latest in-app billing v3.

The basics: 

I have currency. 

This currency is earned or purchased. 

Currency is given to players periodically.

Currency can be purchased in lots (1,5,10,20,50,100) or atleast that is what I wanted.

Google Play v3 forces you to store ownership details of consumable items on their servers.

You can not purchase the same item over until it is consumed first, removed from ownership according to google, and therefore not possessed in your game any more.

This presents some really painful problems to resolve if I am understanding this correctly. Unless I can I just consume the “lot of currency” item purchased immediately after purchase? And if I do that but I don’t yet have a server implementation to store player data, will that present a problem upon submission? 

How else could you handle it?

Do you make a ton of “duplicate” store items to handle the players ability to make multiple purchases of the same item should he want to restock? Can you make free items that are tracked? 

What if the player buys a 100 pack, uses 99. Then uninstalls and moves to another device? He’ll get all 100 back. How do you handle that?

So how should I manage purchased currency? Can anyone suggest any decent strategies to handle this?

Thanks,

Gullie

I use the store purchase transaction callback state to consume the purchase.  If the purchase was successful the event.transaction state will be ‘purchased’ and I then call a store.consumePurchase with the same item SKU that was just purchased.  The item then becomes available to buy again, including across devices and uninstalls/reinstalls.  You don’t need a server to manage any of this, Google handles it all.

EDIT:  Of course you will still need to store the new currency balance locally on the player’s device.  “Consuming” the currency doesn’t mean the user necessarily used it yet in the game, just that they now have a balance of your currency on their device.  If you want the user to be able to uninstall and reinstall the app and yet retain their old currency balance then you would need a way to store that balance info, player data/account on your own server or hosted somewhere, which would add a lot of complexity to the implementation.

Think of consumption not so much in the user having “consumed” the item, i.e. like drinking that potion the bought, but in that your app has used it to add to their inventory and you’re clearing a flag that prevents people from buying it again immediately.

You can consider adding it to their bank account as consuming it.  As Stephen said, just call store.consumePurchase() in the transaction call back listener for the purchase.

Rob

Thanks for the tips. The way google phrased it, I felt like the purchase needed to actually be consumed in game in order to clear Google’s consume flag. Otherwise I assumed that the app would be rejected…

I use the store purchase transaction callback state to consume the purchase.  If the purchase was successful the event.transaction state will be ‘purchased’ and I then call a store.consumePurchase with the same item SKU that was just purchased.  The item then becomes available to buy again, including across devices and uninstalls/reinstalls.  You don’t need a server to manage any of this, Google handles it all.

EDIT:  Of course you will still need to store the new currency balance locally on the player’s device.  “Consuming” the currency doesn’t mean the user necessarily used it yet in the game, just that they now have a balance of your currency on their device.  If you want the user to be able to uninstall and reinstall the app and yet retain their old currency balance then you would need a way to store that balance info, player data/account on your own server or hosted somewhere, which would add a lot of complexity to the implementation.

Think of consumption not so much in the user having “consumed” the item, i.e. like drinking that potion the bought, but in that your app has used it to add to their inventory and you’re clearing a flag that prevents people from buying it again immediately.

You can consider adding it to their bank account as consuming it.  As Stephen said, just call store.consumePurchase() in the transaction call back listener for the purchase.

Rob

Thanks for the tips. The way google phrased it, I felt like the purchase needed to actually be consumed in game in order to clear Google’s consume flag. Otherwise I assumed that the app would be rejected…