Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Need to be able to restore consumable IAP for in-game currency

Discussion in 'Unity IAP' started by GrayLightGames, Nov 30, 2019.

  1. GrayLightGames

    GrayLightGames

    Joined:
    Jan 14, 2015
    Posts:
    30
    I am creating a game intending to use in-game currency bought using consumable IAP. These purchases are not restored when a user reinstalls or changes device. I have seen workarounds using iCloud, keychain, my own server or a file. Special handling for iCloud and keychain violates a unified approach, files are easily abused and cumbersome for the user, and if I want to run a server, why am I using IAP and paying 30%?

    Two questions:
    1. What is the prescribed way to handle in-game currency using Unity IAP? How should I handle reinstalls and device changes so users don't lose their currency? Or in fact, any consumables for that matter.
    2. Can we request/make a case for adding consumable restoration functionality?
    Given the number of posted workarounds, a number of other developers would like this. Maybe I'm missing something, but I don't see a good reason why I can't restore consumables... I have a simple system in place that tracks the usage against the purchases... if a user reinstalls or changes devices, I'd like them to get all their purchased currency back. So if the limitation is to protect developers, let us decide if we want to restore them or not.

    If the main issue is just that Apple doesn't do it this way, can we get together and ask them to?

    Any help or advice would be welcomed and appreciated! I did try to find a discussion aimed specifically at this particular aspect of IAP... if there is a conversation already underway, would love a redirect.

    Thanks!
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Consumable products won't be restored, this is by design by the stores. A user could purchase "50 gold coins" once, and restore over and over and the developer would lose sales. You'll need to track user purchases, some studios save purchases to the cloud.
     
  3. GrayLightGames

    GrayLightGames

    Joined:
    Jan 14, 2015
    Posts:
    30
    Thanks for the reply Jeff!

    If consumables were included, restoring would just give me all the purchases the user has ever made right? So if I maintain a local purchase record on the device that receives the purchase history from the store, then I can just wipe that local purchase record on restore and I would only ever reflect the 50 coins. Then I compare the purchase record to a locally maintained usage record and the difference is what the user has available. A similar system would be required if I track the purchases myself.

    If they reinstall or change devices, they lose the usage record but they still get the 50 coins so they can buy the same things again.

    Seems like a simple thing to implement on my side, is that the main reason consumables don't restore? My game is a completely local experience where purchasing is the only reason to connect elsewhere, so implementing something in the cloud seems like needless overhead. Something I'm missing?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    So in your scenario, a user would have unlimited coins, not just 50. As a user, I could pay 99 cents for 50 coins and play for an hour until I'm almost out of coins. Then do your restore, and I would have 50 coins again, without paying. But to be clear, we are only a pass through service for the stores, we don't add any additional functionality as you suggest. It would be up to the stores, you are welcome to contact Google and/or Apple with your suggestion.
     
  5. GrayLightGames

    GrayLightGames

    Joined:
    Jan 14, 2015
    Posts:
    30
    I have a message out to Apple support, sending one to Google as well... but I'm sure there would be a much higher chance of something being done if someone from Unity asked for this on behalf of their customers. Is there someone on the Unity side that interfaces with Apple and Google on these kinds of issues?

    Sorry, maybe I'm not explaining my solution properly. So someone buys 50 coins. Locally on the device, I track purchasedCoins and usedCoins. Your available coins would be purchasedCoins - usedCoins. You play for your hour and use 45 coins leaving you with 5. Then you restore and when you restore, I set purchasedCoins to 0. Then add the 50 from the consumable transaction(s). So now purchasedCoins is again 50, and usedCoins is still 45. So availableCoins would still be only 5 (50 purchased coins - 45 used coins). If I added coins without zeroing out purchasedCoins, it would be as you describe.

    Does that make sense? It's a simple solution that allows players to keep their consumables across devices and reinstalls without needing a server or cloud storage. I'd like to be able to offer that to my customers without needing cloud storage or running a server.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Let's say the user has 5 coins left on the first device. They do a restore on a second device, and you want them to have 5 coins on that second device. But how does the second device know how many coins are remaining from game play on the first device? But let's say you use those 5 coins up on the second device, what happens now on the first device? Are you telling Google each time how many coins have been used on each device? How would the first device know that the second device used up the 5 remaining coins? How would the second device know there are 5 coins left out of 50? I understand what you are trying to do, but I think your time might be better put into making a great game!
     
  7. GrayLightGames

    GrayLightGames

    Joined:
    Jan 14, 2015
    Posts:
    30
    It's a good question you're asking... the way I have been thinking, the usage part would be totally separate on each device. So when they install on Device 2, they would just start at the beginning of the game with 50 coins to spend. Device 1 will be part of the way through the game with 5 coins to spend and Device 2 would be at the beginning with 50. Sure you lose all your progress, but at least you can re-spend the coins if you'd like to keep playing. In fact, one of my consumables allows you to skip levels, so having all the coins you've spent back may help some people catch back up. The alternative being start from the beginning with 0 coins.

    Thanks for the encouragement, game is pretty close to done... sorting out the economic system is one of my last steps! I'm sure if I could convince someone to add this functionality, it wouldn't be in time for this game I'm soon to release... would be nice for the next games though or as an update to this one. Just trying to look out for my future customers.