Proper way to connect wallet and google store credits

Hey guys,

We’re connecting our store with google play and ran into some integration problems:

  1. Is there a guide to an endpoint or something to let google play make a callback and update the user’s wallet?
  2. Is it possible to create custom REST http endpoint within nakama?
  3. What is the right way to integrate Google play store or Apple store with nakama’s wallet system?

Thanks!

@arxdsilva There’s a bunch of different ways to solve these requirements for your game and it depends on how you structure your purchase codes in Apple AppStore and Google Play.

A typical approach with Nakama is to create a collection of generic purchase codes in each of the stores that match to a specific price range. Then inside the game server maintain a storage object or static set which maps an in-game purchase-able item to the purchase code. These can then be surfaced in a store for the player to purchase within your UI.

const shopSkuCodes = {
    "mini_gems": "com.mygame.name.prod.mini_gems",
    "small_gems": "com.mygame.name.prod.small_gems",
    "medium_gems": "com.mygame.name.prod.medium_gems"
};

The code above is used to map a purchase-able item name to an SKU code in the store set up for the game.

  1. Is there a guide to an endpoint or something to let google play make a callback and update the user’s wallet?

There’s no callback in Google Play as far as I’m aware to receive a purchase from a user. Instead the game client must submit the receipt to the server (usually in an RPC) which would then validate the receipt and take out the product code to be able to apply the purchase to the user’s wallet.

  1. Is it possible to create custom REST http endpoint within nakama?

Yes these are called RPCs in Nakama. You can read more about them in the documentation but in short they’re like a cloud function or lambda function which you can write your own logic for in Go, Lua, or TypeScript.

What is the right way to integrate Google play store or Apple store with nakama’s wallet system?

Right now the best way is to write your own RPC function which takes the mapping you’ve created that I gave an example of above and can grant the purchase-able items to the player after the IAP receipt is validated.

We’ve provided some Lua code which shows how to validate a receipt though you should also subscribe to this pull request where we’ve added first-class functions to the Nakama Server Framework to make it easier to do IAP validation and handle receipt replay attacks.

I can give better examples if you’ve got some specific examples of purchase-able items you want to handle in your game. Hope this helps.

2 Likes

Thank you @novabyte. I’ll do it soon and maybe document it in nakama-docs, is there a proper place to do so?

@arxdsilva There’s no good place in the docs for this kind of content yet but it would be great to have some kind of resource on it. If there’s any content you get time to put together let me know and I’ll find a place for it in the docs. :+1:

1 Like