Skip to content

In-app purchases (Construct 3)

The plugin exposes IAP as event‑sheet actions, triggers, and expressions — no JavaScript. The underlying store (Facebook IAP, Apple IAP, Google Play Billing, …) is whichever the current channel uses; you don’t pick it. Catalog concepts live in Web SDK IAP.

Actions

ActionDoes
Check if IAP is readyIs the store initialized? Result on the IAPReadyStatus expression (1/0).
Get IAP catalogFetch the catalog. Result on LastCatalog (JSON).
Get product by IDFetch one product. Result on LastProduct (JSON).
Purchase productStart checkout — Product ID (+ optional metadata JSON).
Consume purchaseMark a consumable delivered so it can be bought again — pass the purchase.
Get unconsumed purchasesFetch consumables not yet consumed (startup recovery).
Configure IAPApply IAP configuration JSON.

Triggers

TriggerFires when
On purchase successCheckout completed — grant content. Read LastPurchase.
On purchase cancelledUser closed the store sheet — not an error.
On purchase unknown productThe product ID isn’t in the catalog.
On purchase errorPurchase / consume / restore failed. Read LastIAPError.
On purchase consumedA consume finished. Read LastConsumedPurchaseId.
On unconsumed purchases retrievedThe unconsumed list is ready. Read LastUnconsumedPurchases.
On IAP configuredConfigure IAP finished.

Expressions

ExpressionReturns
FRVR SDK.LastPurchaseMost recent successful purchase (JSON).
FRVR SDK.LastUnconsumedPurchasesArray of unconsumed purchases (JSON).
FRVR SDK.LastConsumedPurchaseIdID of the last consumed purchase.
FRVR SDK.LastCatalogThe catalog (JSON).
FRVR SDK.LastProductLast product fetched by ID (JSON).
FRVR SDK.LastIAPErrorMost recent IAP error message.
FRVR SDK.IAPReadyStatus1 if IAP is ready, else 0.
Condition:  On button "BuyCoins" clicked
Action:     FRVR SDK → Purchase product ("coins_100")

Trigger:    FRVR SDK → On purchase success
Action:     System → Add 100 to Coins
Action:     FRVR SDK → Consume purchase (FRVR SDK.LastPurchase)

Trigger:    FRVR SDK → On purchase error
Action:     Show toast "Purchase failed. Try again."   // FRVR SDK.LastIAPError
  1. Kick off checkout with Purchase product — the Product ID, plus an optional metadata JSON string.
  2. On On purchase success, grant the content. The receipt is on FRVR SDK.LastPurchase (a JSON object). If it’s a consumable, pass it to Consume purchase so the store lets them buy again.
  3. On On purchase error, show the message from FRVR SDK.LastIAPError.

For finer control, handle On purchase cancelled (user backed out — say nothing) and On purchase unknown product (bad product ID) as their own branches.

  • Consumables (coins, gems, lives) — always Consume purchase after granting. When it finishes, On purchase consumed fires and FRVR SDK.LastConsumedPurchaseId holds the id.
  • Durables (remove‑ads, skins, season pass) — never consume; they’d become re‑buyable. Make your grant idempotent so re‑applying it never double‑rewards.

If the app died between purchase and grant — or a consumable was never consumed — Get unconsumed purchases hands you everything still pending, in one shot. (It does not replay On purchase success.)

On start of layout:
  Action:  FRVR SDK → Get unconsumed purchases

Trigger:   FRVR SDK → On unconsumed purchases retrieved
Action:    → parse FRVR SDK.LastUnconsumedPurchases (a JSON array)
           → for each purchase: grant it, then FRVR SDK → Consume purchase (that purchase)

Trigger:   FRVR SDK → On purchase error            // restore failed
Action:    show / log FRVR SDK.LastIAPError

This is exactly FRVR.iap.getUnconsumedPurchases() → loop → consumePurchase(...), with the .catch mapped to On purchase error. Two things to keep in mind:

  • The list arrives via the trigger (and FRVR SDK.LastUnconsumedPurchases), not as a return value — read it inside the trigger, not on the line right after the action.
  • The plugin gives you the whole list as one JSON array; load it into a Construct JSON object and loop the entries yourself.
Action:  FRVR SDK → Get IAP catalog
         // result lands on FRVR SDK.LastCatalog (JSON string)

There’s no “catalog ready” trigger — the result is stored on FRVR SDK.LastCatalog (and FRVR SDK.LastProduct for Get product by ID). Read it a tick or two after calling the action, then parse the JSON to build your shop UI. Prices are already localized to the player’s currency — don’t hard‑code them.