# 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 <a href="#support-1" id="support-1"></a>

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

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FWuTw0rt2uidJzc84if2E%2FScreenshot%202025-01-22%20at%2013.16.05.png?alt=media&#x26;token=c8194002-3057-4292-8fca-b096bdf51fe7" alt=""><figcaption></figcaption></figure>

#### Setup <a href="#purchase" id="purchase"></a>

Setup in-game purchases in the [config file](https://wiki.playgama.com/playgama/sdk/engines/setup#config). For each product add an `id` and fill in the information for the required platforms, example for one product:

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

#### Purchase <a href="#purchase" id="purchase"></a>

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

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FGFfdxX0NvJ1spXaQCqbC%2FScreenshot%202025-12-12%20at%2011.18.42.png?alt=media&#x26;token=62ef546b-7999-431d-8ce9-ce1317d5263e" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button","\"Left\""]}],"actions":[{"type":{"value":"PlaygamaBridge::PaymentsPurchase"},"parameters":["","\"test_product\"","\"{\\\"id\\\":\\\"P-1023\\\",\\\"item\\\":\\\"Magic Potion\\\",\\\"price\\\":12.5,\\\"qty\\\":1}\"",""]},{"type":{"value":"PlaygamaBridge::AddActionParameter"},"parameters":["","\"price\"","\"100\"",""]},{"type":{"value":"PlaygamaBridge::AddActionParameter"},"parameters":["","\"name\"","\"magic potion\"",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnPaymentsPurchaseCompleted"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["PlaygamaBridge::PaymentsLastPurchasePropertyValue(\"options.name\")","\"info\"",""]}]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["PlaygamaBridge::PaymentsLastPurchasePropertyValue(\"options.name\")","\"info\"",""]}]}],"eventsCount":3,"actionsList":[],"actionsCount":0,"conditionsList":[{"type":{"value":"PlaygamaBridge::OnPaymentsPurchaseCompleted"},"parameters":["",""]},{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"conditionsCount":2}}
```

</details>

Use `Purchase` data to verify the purchase. Currently `playgama`, `msn` and `microsoft_store` platforms support verification.&#x20;

```bash
curl -X POST "https://playgama.com/api/bridge/v1/verify" \
  -H "Content-Type: application/json" \
  -d '{"platform":"<bridge.platform.id>","type":"purchase","data":{ <...Purchase> }}'

#  Response:
#  {
#    success: boolean;
#    errorMessage?: string;

#    -- purchase --
#    orderId?: string;
#    productId?: string;
#    externalId?: string;
#  }
```

#### Consume Purchase

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

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FF5S7j2xgblYYYcbeAwmo%2FScreenshot%202025-12-08%20at%2015.50.39.png?alt=media&#x26;token=ee36c03e-dbce-42b4-a65d-a5b2e6e155c2" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::PaymentsConsumePurchase"},"parameters":["","\"test_product\"",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnPaymentsConsumePurchaseCompleted"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Consume completed, id: \" + PlaygamaBridge::PaymentsLastPurchasePropertyValue(\"id\")","\"info\"",""]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>

Each platform provides its own set of properties for a purchase (which you can access through `PlaygamaBridge::PaymentsLastPurchasePropertyValue`), so make sure to check the official documentation of the specific platform you are targeting.

#### Catalog of All Items <a href="#catalog-of-all-items" id="catalog-of-all-items"></a>

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

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FmFGYbqt3VxA0aGQ01ECd%2FScreenshot%202025-12-10%20at%2023.28.17.png?alt=media&#x26;token=2163c1c0-e55b-4ee0-893c-6ea69c302f1c" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy Example</summary>

```
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::PaymentsGetCatalog"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnPaymentsGetCatalogCompleted"},"parameters":["",""]}],"actions":[{"type":{"value":"SetNumberVariable"},"parameters":["loopindex","=","0"]}],"events":[{"type":"BuiltinCommonInstructions::Repeat","repeatExpression":"PlaygamaBridge::PaymentsCatalogItemsCount()","conditions":[],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"ID:\" + PlaygamaBridge::PaymentsCatalogItemPropertyValue(loopindex, \"id\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Price:\" + PlaygamaBridge::PaymentsCatalogItemPropertyValue(loopindex, \"price\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Price Currency Code:\" + PlaygamaBridge::PaymentsCatalogItemPropertyValue(loopindex, \"priceCurrencyCode\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Price Value:\" + PlaygamaBridge::PaymentsCatalogItemPropertyValue(loopindex, \"priceValue\")","\"info\"",""]},{"type":{"value":"SetNumberVariable"},"parameters":["loopindex","+","1"]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>

#### List of Purchased Items <a href="#list-of-purchased-items" id="list-of-purchased-items"></a>

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

{% hint style="warning" %}
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).
{% endhint %}

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F7r4wbwvE5bssOxHidPGe%2FScreenshot%202025-12-10%20at%2023.20.40.png?alt=media&#x26;token=a0e20b2a-7196-4337-ac27-115c17e5b8a5" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::PaymentsGetPurchases"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnPaymentsGetPurchasesCompleted"},"parameters":["",""]}],"actions":[{"type":{"value":"SetNumberVariable"},"parameters":["loopindex","=","0"]}],"events":[{"type":"BuiltinCommonInstructions::Repeat","repeatExpression":"PlaygamaBridge::PaymentsPurchasesCount()","conditions":[],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"ID:\" + PlaygamaBridge::PaymentsPurchasePropertyValue(loopindex, \"id\")","\"info\"",""]},{"type":{"value":"SetNumberVariable"},"parameters":["loopindex","+","1"]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>
