How do I Restore Purchases for In Game Currency using IAP?

0 favourites
  • 12 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Recently my app was rejected from the iOS store again because it did not include a restore purchases button. The only IAPs in my game are a few consumable options to buy more in game currency but they are saved to the local storage. How do I make a restore purchases button? Also what would it do in my game?

    ***EDIT*** Okay so after making a restore purchases button and playing around with the restore action, the restore purchases button in my game adds on the amount of coins that the player has bought but it continuously adds on coins even if the device wasn't switched or if the restore purchases button is being clicked over and over again. For example, when I buy 1000 coins, I can click the restore purchases buttons as many times and it will continue adding 1000 coins. How do I test if the device was switched? I'm testing in testflight if that helps.

    Also, some possible solutions I've tried to think up is adding a variable that prevents the player from clicking the restore purchases button more than once and then resetting the restore purchases button to make it clickable again when the player buys a new product but I'm almost certain this wouldn't work. Has anyone found a solution or knows how to use the restore purchases action?

    It's been almost two months of troubleshooting the IAP object so I'm desperate for answers. Any help is appreciated.

  • bump

  • I've not used the IAP but it sounds like you need a variable to control how many times the IAP previous purchase amount can be added into your events.

  • Colludium that would make sense but the restore purchases button is only applicable when the player somehow deletes his local storage data like by uninstalling or reinstalling the app or switching to a new phone. I'm not sure how I would detect that.

  • I read it that the problem you had was continuous / repeated adding of restored coins. So, you need a condition event to prevent that from happening more than once (by using a variable somewhere that changes when the restore action takes place).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just have a variable in your localstorage that checks if its a new install or not, if it is, he can restore his coins, else not.

    A simple boolean would be fine.

    In my example, players can buy skins for a character ingame and this is the part that checks if he has the purchase IF the value is not in the array.

  • Wishy that sounds like it would work but how would I test if its a new install or not?

  • I test it by having a reset button in my game, which clears all data, resets global variables and removes localstorage.

    I usually also remove my app-cache and data before trying a fresh install.

    If you mean, how does the game know it's a fresh install, well, because the variable/array is empty.

    You could also make a variable "IsFreshInstall" set to 0 after the game has started (and have it saved in localstorage).

    So the next time the game is started it will know it's not a fresh install.

    like this:

  • Wishy thank you. That's very helpful to know. I'm working on incorporating it right now

  • Wishy if I set IsFreshInstall to 0 on start of layout and then tested if it was equal to 1, wouldn't it always be equal to 0 making it impossible to restore purchases? For instance, I'm saying If IsFreshInstall is 1 and On clicked button then restore purchases but IsFreshInstall is always 0.

  • Wishy that sounds like it would work but how would I test if its a new install or not?

    Hi HZGaming,

    the best way in my opinion (requires some knowledge in with AJAX plugin, also MySQL and a little PHP is needed) is, building up your own little framework/api where a user has the option to register (not speaking of Facebook - or something you dont want to have ; Username & PW is totally enough.. maybe an optional mail-address for beeing able to recover his password). This enables such great ways and features to extend an app (having the same savegame on different devices, etc.).

    I think in any way you should head for some webstored data (speaking of MySQL, PHP-to-TXT-Scripts, etc.). When I read "Restore purchases" I understand "restore them under any circumsances", meaning: even when flashing a new ROM to your device or changing it (after a guarantee repair, for example), I am able to restore them.

    An another way could be including Google Play services into your project (there are plenty tutorials in the forums/tutorial-section for it) - but even then, if you want to cover all scenarios of loosing data, you have to store things externally of a device (where MySQL comes back again ;D).

    Good luck with your project and have a great weekend,

    Proxy

  • Wishy if I set IsFreshInstall to 0 on start of layout and then tested if it was equal to 1, wouldn't it always be equal to 0 making it impossible to restore purchases? For instance, I'm saying If IsFreshInstall is 1 and On clicked button then restore purchases but IsFreshInstall is always 0.

    Well you put your restore actions there before you set it to 0.

    I also said you'll have to save it into your localstorage.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)