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., removing ads) 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

Check if in-game purchases are supported on the platform.

Purchase

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

func _ready():
    var options

    match Bridge.platform.id:
        "yandex":
            options = {
                "id": "PURCHASE_ID"
            }

    Bridge.payments.purchase(options, funcref(self, "_on_purchase_completed"))

func _on_purchase_completed(success):
    print(success)

Consumable

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

func _ready():
    var options

    match Bridge.platform.id:
        "yandex":
            options = {
                "purchaseToken": "PURCHASE_TOKEN"
            }

    Bridge.payments.consume_purchase(options, funcref(self, "_on_consume_completed"))

func _on_consume_completed(success):
    print(success)

Catalog of All Items

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

func _ready():
    Bridge.payments.get_catalog(funcref(self, "_on_get_catalog_completed"))

func _on_get_catalog_completed(success, catalog):
    print(success)
    
    match Bridge.platform.id:
        "yandex":
            for item in catalog:
                print("ID: " + str(item.id))
                print("Title: " + str(item.title))
                print("Description: " + str(item.description))
                print("Image: " + str(item.imageURI))
                print("Price: " + str(item.price))
                print("Price Currency Code: " + str(item.priceCurrencyCode))
                print("Price Currency Image: " + str(item.priceCurrencyImage))
                print("Price Value: " + str(item.priceValue))

List of Purchased Items

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

func _ready():
    Bridge.payments.get_purchases(funcref(self, "_on_get_purchases_completed"))

func _on_get_purchases_completed(success, purchases):
    print(success)
    
    match Bridge.platform.id:
        "yandex":
            for purchase in purchases:
                print("Product Id: " + str(purchase.productID))
                print("Purchase Token: " + str(purchase.purchaseToken))

Last updated