Allow players to buy items or upgrades in your game to enhance their gameplay experience.
local bridge = require("bridge.bridge")
function init(self)
local commonId = "test_product" -- commonId you specified in the config file
bridge.payments.purchase("test_product", 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 commonId = "test_product" -- commonId you specified in the config file
bridge.payments.consume_purchase(commonId, function ()
-- 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 commonId = value.commonId
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.
If the user loses internet connection when making an in-game purchase, the purchase might remain unprocessed. To avoid this, check for unprocessed purchases using this method (e.g., each time the game is launched).
local bridge = require("bridge.bridge")
function init(self)
bridge.payments.get_purchases(function (_, purchases)
-- success
for key, value in pairs(purchases) do
local commonId = value.commonId
end
end, function ()
-- error
end)
end