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. Dismiss Notice

How to make server & DB for Android/iOS in-app-purchase?

Discussion in 'Multiplayer' started by leegod, Jul 9, 2014.

  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    Hi, I am making mobile game (android/ios) and have questions about in-app-purchase item and game server.

    1.
    So, as far as I know, for recording and restoring past purchased consumable in-app-item to end users, mobile game which has consumable in-app-purchase items should have its own server & database, right?

    2.
    If then, how make that sort of server and database? What solutions most indie developer uses? PHP & mysql? or other? Is there a tutorial about setup this sort of thing?


    Thanks you in advance.
     
  2. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Not only do you not need a separate database and handler, you can get yourself pulled from the respective store if you do that. You need to look up in app transactions for each platform. I'm not familiar with IOS, but you can find information for Android here: http://developer.android.com/google/play/billing/billing_overview.html

    You essentially connect to the store, and set call back listeners in your app. For non consumable (pay $$ to remove ads, for example), you simply check to see if it is in their purchase history. Consumable items (buy a health potion for $$), is destroyed after purchase or when you tell it to. Note that they cannot buy a non-consumable item twice (ever) and cannot buy another consumable item until it has been consumed.

    There are cheap assets in the asset store that do most of this for you.
     
  3. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    hi, thx for reply, but I know it already.

    But how deal in case of if user change phone or delete game and re-install?

    Then his purchased consumable item all gone. And he will complain to me, and I should restore his remaining paid item.

    How you can do this without DB?
     
  4. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Non-consumable items do not go away. The game should always check their Google inventory to see if they have purchased any, then give it back to them. If they purchase a gun, or a sword, or whatever, then it will always be given to them, no matter what.

    Consumable items (potions, money, arrows, whatever) are another matter. In this case, use Google Cloud saves: https://developers.google.com/games/services/common/concepts/cloudsave. In this way, their data will always remain with and be retrieved from Google. It won't matter if they have to reinstall.

    As far as IOS, I'm not sure, you'll have to do that research on your own.
     
  5. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    Oh thx.
    I didn't know about Google Cloud Saves.

    So this is solution to re-install and phone-change and consumable items?

    So as far as user login-in by same google account he firstly used at my game, he will receive same game state at his new phone(or reinstalled game)?

    Then I don't need to make DB(mysql) & php to store record? Except iOS version's consumable items?
     
  6. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Actually, from the look of it, Google cloud saves may work for IOS as well. I know Google has an entire game service now that is compatible with IOS. It makes sense that the cloud saves would work with it as well. I think it would be worth your time to investigate using that over maintaining a database.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    iOS IAP plugins (such as Prime31 StoreKit) have a one line method called RestorePurchases which does what you want.

    I normally don't recommend Prime31 stuff since their support isn't the most helpful, but StoreKit is the one Prime31 plugin we still use because it's pretty good.
     
  8. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    Does that also restore consumable inapp items too?

    And how know about user's identity? User's apple ID? or?
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    No it doesn't restore consumable items. You're not supposed to do that anyway, as it could lead to "infinite free IAPs". Because you have no way of knowing whether they used 0 or 5 of the 5 bombs they bought. So if you restored an IAP of 5 bombs, they would get all 5 again. And they could use all 5 and restore purchases again to get 5 more. As many times as they want.

    Yes, they have to log in with their Apple ID to restore purchases.
     
  10. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    So that means, for iOS game, developer still need to make game's specific DB for store and record user's paid item usage status.
     
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    No, it means consumable items are simply lost when you change devices. No reason to need to track that.
     
  12. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    I think it has reason. What if user complain to developer restore his unused consumable item he purchased?
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Well that's standard practice. There's a reason you don't restore those as I explained above. They could infinitely reuse consumables for FREE pretty much no matter what you do. Even if they have to resort to continually uninstalling and installing the game to do so.
     
  14. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Again, Google Cloud Saves is what you want. It works for both IOS and Android and saves the state of the game, so all unused items, stats, whatever. If all you are doing with the database is saving a few items, you're opening a walnut with a sledgehammer.
     
  15. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    Ok, so another subject,

    By some googling, anyone can easily find hack program, method for mobile in-app-purchase items.

    How you deal with these problem? What is solutions or ways to block this from the first before release?

    Without measure about this problem, all efforts input in development is useless.

    Thx.
     
  16. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    EA games are hacked within an hour of their release. Does EA still make games?

    The bottom line is that there is no solution. You make the game and get whatever you're paid, and that's pretty much it. If you want to make it unhackable, you'll never finish a game. If you want to make it difficult (2 hours instead of 1 hour to hack) then you're doubling your development time.

    As frustrating as it is, it's just something that developers have to learn to live with at the moment.
     
    Lexudau likes this.