In-Game Purchases

Enable players to purchase items, upgrades, or currency within your game to enhance their experience and generate revenue.

There are two types of purchases — permanent (e.g., ad removal) and consumable (e.g., in-game coins).

Support

Check if in-game purchases are supported to offer items or upgrades within the game.

bridge.payments.is_supported()

Setup

Setup in-game purchases in the config file. For each product add an id and fill in the information for the required platforms, example for one product:

{
    ...    
    "payments": [
        {
            "id": "test_product",
            "playgama": {
                "amount": 1 // int price in Golden Fennec
            },
            "playdeck": {
                "amount": 1, // int price in Telegram Stars
                "description": "TEST PRODUCT"
            }
        }
    ]
}

Purchase

Allow players to buy items or upgrades in your game to enhance their gameplay experience.

local bridge = require("bridge.bridge")

function init(self)
    local id = "test_product" -- id you specified in the config file
    bridge.payments.purchase(id, function (_, purchase)
        -- success
    end, function (_, error)
        -- error
    end)
end

Consume Purchase

Consume purchased items, such as in-game currency, once they are used, to manage inventory and player progression.

local bridge = require("bridge.bridge")

function init(self)
    local id = "test_product" -- id you specified in the config file
    bridge.payments.consume_purchase(id, function (_, purchase)
        -- success
    end, function ()
        -- error
    end)
end

Catalog of All Items

Retrieve a list of all available in-game items that players can purchase to display in the game store.

local bridge = require("bridge.bridge")

function init(self)
    bridge.payments.get_catalog(function (_, catalog)
        -- success
        for key, value in pairs(catalog) do
            local id = value.id
            local price = value.price
            local priceCurrencyCode = value.priceCurrenyCode
            local priceValue = value.priceValue
        end
    end, function ()
        -- error
    end)
end

List of Purchased Items

Retrieve a list of items that the player has purchased to manage their inventory and provide access to purchased content.

local bridge = require("bridge.bridge")

function init(self)
    bridge.payments.get_purchases(function (_, purchases)
        -- success
        for key, value in pairs(purchases) do
            local id = value.id
        end
    end, function ()
        -- error
    end)
end

Last updated