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.
What the plugin gives you
Section titled “What the plugin gives you”Actions
| Action | Does |
|---|---|
| Check if IAP is ready | Is the store initialized? Result on the IAPReadyStatus expression (1/0). |
| Get IAP catalog | Fetch the catalog. Result on LastCatalog (JSON). |
| Get product by ID | Fetch one product. Result on LastProduct (JSON). |
| Purchase product | Start checkout — Product ID (+ optional metadata JSON). |
| Consume purchase | Mark a consumable delivered so it can be bought again — pass the purchase. |
| Get unconsumed purchases | Fetch consumables not yet consumed (startup recovery). |
| Configure IAP | Apply IAP configuration JSON. |
Triggers
| Trigger | Fires when |
|---|---|
| On purchase success | Checkout completed — grant content. Read LastPurchase. |
| On purchase cancelled | User closed the store sheet — not an error. |
| On purchase unknown product | The product ID isn’t in the catalog. |
| On purchase error | Purchase / consume / restore failed. Read LastIAPError. |
| On purchase consumed | A consume finished. Read LastConsumedPurchaseId. |
| On unconsumed purchases retrieved | The unconsumed list is ready. Read LastUnconsumedPurchases. |
| On IAP configured | Configure IAP finished. |
Expressions
| Expression | Returns |
|---|---|
FRVR SDK.LastPurchase | Most recent successful purchase (JSON). |
FRVR SDK.LastUnconsumedPurchases | Array of unconsumed purchases (JSON). |
FRVR SDK.LastConsumedPurchaseId | ID of the last consumed purchase. |
FRVR SDK.LastCatalog | The catalog (JSON). |
FRVR SDK.LastProduct | Last product fetched by ID (JSON). |
FRVR SDK.LastIAPError | Most recent IAP error message. |
FRVR SDK.IAPReadyStatus | 1 if IAP is ready, else 0. |
Buy a product
Section titled “Buy a product”- Kick off checkout with Purchase product — the Product ID, plus an optional metadata JSON string.
- 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. - 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 vs. durables
Section titled “Consumables vs. durables”- Consumables (coins, gems, lives) — always Consume purchase after granting. When it finishes, On purchase consumed fires and
FRVR SDK.LastConsumedPurchaseIdholds 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.
Restoring unfinished purchases
Section titled “Restoring unfinished purchases”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.)
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.
Reading the catalog
Section titled “Reading the catalog”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.