In-app purchases (Cocos)
FRVRSDK.instance exposes a full IAP surface for Cocos. The backing store (Facebook IAP, Apple IAP, Google Play Billing, …) is whichever one the host channel uses — you don’t pick it.
Is it ready?
Section titled “Is it ready?”Call this before populating shop UI. The catalog takes a moment to resolve on session start.
Read the catalog
Section titled “Read the catalog”Use product.price directly in button labels — it’s already localized to the player’s currency.
Purchase
Section titled “Purchase”purchase is null / undefined if the user cancelled or the purchase failed. Don’t show an error in those cases — the store UI already handled them.
Purchase receipt shape
Section titled “Purchase receipt shape”Consumables vs. durables
Section titled “Consumables vs. durables”- Consumables (coins, lives, event currency) — call
consumePurchase()after granting, so the store allows re‑buying. - Durables (remove‑ads, premium skins, season pass) — do not consume. If the player reinstalls or switches devices, restore them via the unconsumed‑purchases check below.
Recover from crashes on startup
Section titled “Recover from crashes on startup”If the game crashed between a successful purchase and granting the item, the store keeps the receipt in a pending state. Run this at boot:
This is also how you restore durables on a new device — granting a durable is idempotent in your own code, so it’s safe to re‑run.
Related
Section titled “Related”- Product catalog setup, error‑type semantics: Web SDK IAP.