Own server, Not using DBManager



  • Hello,

    I would like to ask if not using dbmanager is possible.

    I am currently storing all client data externally in mysql database and all game logic is done server side. So nothing is stored locally and all data is retrieved at login time and synchronized when something changes server side.

    So what I would like to do is to just send a update to the server with currency amount when the purchase receipt is sucessfuly verified.

    Is something like this possible?
    I am assuming it should be as simple as adding the server calls to the HandleSuccessfulPurchase method instead of the DBManager calls would this be correct ?

    I am only planning to sell virtual currency for real money .

    All other items will be bought using the virtual currency. And these transactions will handled by my server so I only need to use the Simple IAP system for purchasing the virtual currency if that makes any sense.

    Thank you



  • Hi,

    if you have a look at the IAPManager prefab, where the DBManager script is attached to, you will notice a checkbox:

    memoryOnly
    Should purchase data only be saved in device memory rather than on disk? Warning: if you do not use some cloud save provider and login system (like PlayFab), your user's purchases will only exist throughout the current game session.

    Additionally, you should disable IAPManager's initialization until you've logged in the user and got the data from your server (and call IAPManager.GetInstance().Initialize later manually):

    autoInitialize
    Toggle that defines whether the IAPManager should initialize itself on first load.

    @fistuge said in Not using DBManager:

    So what I would like to do is to just send a update to the server with currency amount when the purchase receipt is sucessfuly verified.

    This is a bit unclear to me. Do you mean the app initiates or sends a request to the server, for adding currency? If so, this should definitely not be in the HandleSuccessfulPurchase method. Actually, it should not be in the app at all. Receipt validation happens on the server, not in the client - your users could send arbitrary amounts of currency to your server, which could all be faked. The workflow would not work this way.

    If your user logs in at app launch, it should receive content progress and currencies from your server. Currency purchases using real money should be initiated by the app, handled by your server (which contacts the App Store), then send back to the app (basically a successful/unsuccessful response is sufficient). Virtual purchases are handled by your server too, so that it always stores the most recent data.

    From your post, I get the impression that you do most of these things already. If you are only missing the server side receipt validation part, you could take a look at our php script and implement it on your server. For virtual items, you would need to modify our IAPManager.PurchaseProduct(IAPObject obj) method, in order to contact your server (for doing the purchase) too. If you would be using PlayFab, our integration basically handles everything of this already.



  • Thank you for your reply ,

    I think adding the server validation makes most sense because I don’t have much experience with playfab.

    Can I use playfab if I am using my own account system ?
    Would it be complicated to make the playfab notify the server when player makes successful/unsuccessful transaction ?

    Also thank you for pointing out the problem with method I suggested. Now that I think about it, it is pretty stupid as it defeats the whole point of the purchase validation.



  • Can I use playfab if I am using my own account system ?

    Yes, users need to login with PlayFab though, before being able to make PlayFab API calls. They provide a LoginWithCustomID method which could be provided by your account system.

    Would it be complicated to make the playfab notify the server when player makes successful/unsuccessful transaction ?

    This is actually easy. PlayFab offers PlayStream events, which are invoked at different player actions. You would be looking at the player_inventory_item_added event. PlayStream events can fire off CloudScript methods - your own code (in javascript or C#) running on their servers. With CloudScript, you can contact your own server in a server-server environment.

    For more information, I would like to point you to the PlayFab forums :)

    As a summary, you have several options:

    • use our server-side validation script as a base and implement it on your own server. Make modifications to our PurchaseProduct methods, to also contact your server not only on real money purchases, but also on virtual purchases.
    • use our Simple IAP System <> PlayFab integration, which means also using PlayFab's login system and inventory management, including receipt validation.
    • use a mix of everything as described above. E.g. receipt validation via PlayFab, but your own login and inventory management.

    There is a lot of custom coding involved. If you're good at coding, and already have your account system and server database set up, I would possibly go with option 1 (add receipt validation too and do everything on your server).



  • @Baron

    I really appreciate you taking your time to write such a detailed response.

    I will look in detail at all the options you listed to see which one will make the most sense for me.

    Thank you for your help!


Log in to reply