In-game purchases let players buy items, upgrades, or currency. Optional, but often the highest-revenue feature for games that fit the IAP model. Enable payments only after ads, storage, and the core game loop are stable.
Two product types
Type
Example
Lifecycle
Permanent
"Remove ads", DLC
Bought once. Use getPurchases() to check ownership on every launch.
Consumable
Coins, gems, energy
Bought, granted, then must be consumed with consumePurchase(id). Until consumed it sits in the purchases list.
After granting in-game items for a consumable purchase, always call consumePurchase(id). Otherwise the purchase remains "active" and purchase(id) calls for the same product will fail.
Support
Check this before showing the store or purchase buttons. If payments are unsupported, hide the IAP UI or use a non-payment fallback.
Does not support:absolute_games, dlightek, game_distribution, gamepush, gamesnacks, jio_games, lagged, ok, poki, samsung, telegram, tiktok, vk, xiaomi, y8, youtube
Setup
Configure products in the config file. Add an id for each product and fill in platform-specific price data. Example for one product:
{..."payments":[{"id":"test_product","playgama":{"amount":1// int price in Gam},"playdeck":{"amount":1,// int price in Telegram Stars"description":"TEST PRODUCT"}}]}
Purchase
Start a purchase flow for the product ID from your config. Call this only from a direct player action, such as pressing a buy button.
Copy This Example
Copy This Example
Each platform returns its own purchase fields. Check the target platform documentation before depending on platform-specific properties.
Use the returned purchase data for backend verification before granting valuable items. Playgama API verification currently supports only playgama, msn, and microsoft_store.
Consume Purchase
Mark a consumable purchase as used after you grant the in-game item. Do not call this for permanent products.
Copy This Example
Copy This Example
Catalog of All Items
Load the product catalog before showing your store. Use it for localized prices, currency codes, and platform-specific product metadata.
Copy Example
Copy Example
List of Purchased Items
Load the player's active purchases on startup and after reconnecting. Use this for permanent ownership checks and unprocessed consumables.
If the player loses connection during a purchase, it can remain unprocessed. Check purchases on every launch and grant or consume any pending items.
func _ready():
var id = "test_product" # id you specified in the config file
var options = { } # optional
Bridge.payments.purchase(id, options, funcref(self, "_on_purchase_completed"))
func _on_purchase_completed(success, purchase):
print(success)
print(purchase)
func _ready():
var id = "test_product" # id you specified in the config file
var options = { } # optional
Bridge.payments.purchase(id, options, Callable(self, "_on_purchase_completed"))
func _on_purchase_completed(success, purchase):
print(success)
print(purchase)
var options = { }
playgama_bridge_payments_purchase("test_product", json_stringify(options)) // id you specified in the config file
// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_payments_purchase_callback" {
if async_load[? "success"] {
var purchase = json_parse(async_load[? "data"])
var productId = purchase.id
// your logic here
}
}
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
var options = { } // optional
bridge.payments.purchase("test_product", options) // id you specified in the config file
.then((purchase) => {
// success
console.log('Purchase completed, id:', purchase.id)
})
.catch(error => {
// error
})
func _ready():
var id = "test_product" # id you specified in the config file
Bridge.payments.consume_purchase(id, funcref(self, "_on_consume_completed"))
func _on_consume_completed(success, purchase):
print(success)
print(purchase)
func _ready():
var id = "test_product" # id you specified in the config file
Bridge.payments.consume_purchase(id, Callable(self, "_on_consume_completed"))
func _on_consume_completed(success, purchase):
print(success)
print(purchase)
playgama_bridge_payments_consume_purchase("test_product") // id you specified in the config file
// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_payments_consume_purchase_callback" {
if async_load[? "success"] {
var purchase = json_parse(async_load[? "data"])
var productId = purchase.id
// your logic here
}
}
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
bridge.payments.consumePurchase("test_product") // id you specified in the config file
.then((purchase) => {
// success
console.log('Consume completed, id:', purchase.id)
})
.catch(error => {
// error
})
playgama_bridge_payments_get_catalog()
// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_payments_get_catalog_callback" {
if async_load[? "success"] {
var catalog = json_parse(async_load[? "data"])
for (var i = 0; i < array_length(catalog); i += 1)
{
var catalogItem = catalog[i]
var productId = catalogItem.id
var price = catalogItem.price
var priceCurrencyCode = catalogItem.priceCurrencyCode
var priceValue = catalogItem.priceValue
// your logic here
}
}
}
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.priceCurrencyCode
local priceValue = value.priceValue
end
end, function ()
-- error
end)
end
func _ready():
Bridge.payments.get_purchases(funcref(self, "_on_get_purchases_completed"))
func _on_get_purchases_completed(success, purchases):
print(success)
for purchase in purchases:
print("ID: " + str(purchase.id))
func _ready():
Bridge.payments.get_purchases(Callable(self, "_on_get_purchases_completed"))
func _on_get_purchases_completed(success, purchases):
print(success)
for purchase in purchases:
print("ID: " + str(purchase.id))
playgama_bridge_payments_get_purchases()
// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_payments_get_purchases_callback" {
if async_load[? "success"] {
var purchases = json_parse(async_load[? "data"])
for (var i = 0; i < array_length(purchases); i += 1)
{
var purchase = purchases[i]
var productId = purchase.id
// your logic here
}
}
}
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