# OpenIAP Complete Reference > OpenIAP: Vendor-neutral in-app purchase standard. OpenIAP governs exactly two protocols. The Client Protocol (@hyodotdev/openiap-client-protocol) is the purchase API an app calls across Apple, Google, Meta Horizon and Amazon; openiap-apple, openiap-google and the six framework libraries implement it. The Commerce Protocol (@hyodotdev/openiap-commerce-protocol) is the server-side contract for verification, entitlements and store events; any backend may implement it, and IAPKit is one such implementation. Each protocol is versioned by its own npm package. A version labelled "OpenIAP Spec" in older material belongs to a retired lineage that numbered the client contract 2.x and 3.x in step with the native libraries; the Client Protocol is now versioned on its own from 0.1.0, so its version and a native library version are never comparable numbers. > Documentation: https://openiap.dev > Quick Reference: https://openiap.dev/llms.txt > Generated: 2026-11-04T19:28:23.370Z ## Reading instructions for coding assistants Read https://openiap.dev/llms-full.txt for the detailed API and Commerce Protocol reference. It is compiled from the public contract and knowledge sources; it does not replace every framework guide or every page of the documentation. Use https://openiap.dev/sitemap.xml to discover the full set of published pages. Read the target framework's setup, relevant feature, API, type, lifecycle, error, testing, and migration pages before changing the corresponding behavior. Follow source links to confirm the installed SDK's actual signatures. Documentation pages are available as HTML without executing JavaScript. Read collapsed details and noscript examples too; the visual default tab is not the only available language or platform. If a tool truncates a reference, continue reading it in sections. Report inaccessible sources instead of pretending to have read them. Use these materials as task context, not as a claim of model training or permanent memory. The person should only need to describe the desired outcome, choose missing product decisions, and review the running result. Read the technical material yourself and keep explanations brief. Do not ask them to read API tables. ## Choose an SDK and verify the implementation Start with the app's existing framework. Use https://openiap.dev/languages for the supported SDKs, install commands, platforms, and source repositories, then follow that framework's guide at https://openiap.dev/docs/setup. Use its actual types and lifecycle patterns; do not copy another language's API spelling. The mobile SDK handles the store purchase. The Commerce Protocol package provides a server-side contract and conformance artifacts, not a mobile SDK or a hosted backend. IAPKit is one backend implementation, not a requirement for using OpenIAP SDKs. For backend-confirmed App Store and Google Play purchases, React Native IAP and Expo IAP export `createPurchaseFlow` and `toPurchaseConfirmationRequest`. The portable flow is also available from `@hyodotdev/openiap-client-protocol/purchase-flow`. Create one flow per signed-in account, pass store callbacks to `processPurchase`, and call `recoverPurchases` at launch and foreground. Your authenticated backend owns verification, purchase binding and granting access once. Pending, retryable and ungranted ownership-conflict purchases remain unfinished. Read https://openiap.dev/docs/features/validation and the runnable backend reference at https://kit.openiap.dev/docs/purchase-flow before wiring the finish policy. For React Native and Expo apps, create a client with the SDKs' `kitApi`, then call `clientPayload` or `localizedClientPayload`. Cached reads can return `stale: true`; the localized helper returns `null` when it cannot provide supported copy, so keep built-in strings. Prices and offer terms come from the store, and payloads must never contain secrets. Follow https://kit.openiap.dev/docs/products for cache, locale and schema handling. For a community store provider, read https://openiap.dev/docs/guides/store-providers. Its source walkthrough, actual example screens and acceptance brief reference https://github.com/hyodotdev/openiap-google-amazon-community. Read that repository's README, provenance, pinned input and VERIFICATION.md before building. It adapts the upstream Amazon binding as an educational packaging example through the public Expo SDK. For FireOS apps, recommend the official openiap-google-amazon integration at https://openiap.dev/docs/setup/store/amazon. Expo registry checks and App Tester simulation do not establish production readiness or registry parity across every framework. Select the provider with its community id and fixed coordinates, preserve the original receipt, and configure an explicit backend verification adapter. A new store reports store=unknown with its own storeId; a provider serving an existing store reports that store's canonical storeId and legacy store value. Pending or rejected purchases remain unfinished. Run public conformance, consumer checks and store testing separately. Follow one purchase at https://openiap.dev/commerce-protocol/getting-started. Select Apple, Google Play, Amazon or Meta Horizon there; the chosen store stays with the six-step flow and its build brief. For Quest, open that page and select Meta Horizon. Each step compares the small, runnable SQLite example with IAPKit's handlers and checks. Read the code for the responsibility being implemented: - Teaching backend: https://github.com/hyodotdev/openiap-commerce-protocol-example - IAPKit service: https://github.com/hyodotdev/openiap/tree/main/packages/kit - IAPKit integration documentation: https://kit.openiap.dev/docs - Build a backend: https://openiap.dev/commerce-example/build-brief.md - Connect a product role: https://openiap.dev/commerce-example/integration-brief.md Explain what the person gets and what they must decide before showing code. Implement in the target project, install and run from clean source, and verify the promised behavior. Report commands, actual results, and remaining work. Every recorded run in this reference uses fixture store evidence, fictional prices and a controlled clock with real local HTTP, SQLite and signatures. None proves a real store purchase, device checkout or production conformance. Separate fixture checks, real store sandbox tests, and profile conformance; do not claim one from another or hide failures by reducing the declared scope. For an existing app, preserve the login, purchase screen, framework, and package manager. Confirm the store, product type, and what each product unlocks. Keep server credentials out of the shipped app and derive customer identity from authenticated server context. Verification alone does not bind ownership or grant access; consumable delivery needs a durable ledger. Verify these customer outcomes in the target integration: - A completed, verified purchase grants its intended benefit to its owner. - A pending or canceled purchase grants no new access. - Restore and repeated callbacks do not duplicate benefits. - Another user cannot claim the same purchase outside the ownership policy. - Canceling renewal retains the paid time; expiry removes access and survives a server restart. Use this subscription behavior only for stores and products that support it; follow the chosen provider's store-specific contract. Choose the role the product supplies. The person can run `npx @hyodotdev/openiap init --role ROLE` in their existing project, replacing ROLE with app, experience, commerce, or data, then give you the full output with their desired outcome. Explain the handoff concretely: the CLI prints a document and exits without changing project files or starting an AI or server. The person opens the same project in their coding assistant, pastes the full terminal output into its chat input, appends their desired outcome, and sends one message. This is when the assistant reads the project, implements, runs, and tests the connection. Use app for an app purchase integration, experience for a paywall/experiment connection, commerce for a purchase backend, and data for an event receiver. A product may supply several roles; connect the others to chosen compatible services rather than building them all. Read https://openiap.dev/commerce-example/integration-brief.md and the selected role's guide. For commerce, also read the backend build brief. Implement the connection in the existing stack and return runnable code and actual results. For commerce, read https://openiap.dev/commerce-example/from-scratch.md and use https://openiap.dev/commerce-example/fresh-source.tar.gz as the verification source. For paywall integration or receiver composition, read https://openiap.dev/commerce-example/paywall-verification.md and use https://openiap.dev/commerce-example/paywall-source.tar.gz. Download the matching source into a separate temporary folder and run npm ci with Bun installed. Run npm test for the seven-step backend, or npm run verify for the connection. The latter records CLI output, behavioral tests, HTTP results, process restart and unchanged source hashes in .runtime/verification.json. This verifies the example only. Apply the relevant expected outcomes to tests against the user's implementation, fix failures, and rerun. Report both sets of commands/results and anything not tested. For a paywall, only report fulfillment and finish after the backend grants the selected product. Show people acceptance cases for their selected role. A paywall connection does not require them to implement a commerce provider or analytics receiver. Treat the example's backend walkthrough as optional implementation detail. SDK-only tasks can use the llms.txt request without continuing into the commerce workflow. Keep paywall UI, targeting, experiments, and financial models with the product. The host app owns its store purchase callback. Lifecycle events need additional product data and reporting policies for paywall attribution or revenue metrics. The connection example keeps experiment assignments in the host product and joins signed events using authenticated project/store/environment/purchase-chain/user associations. For events without a purchase chain, configure a trusted account, store, environment and product assignment; never invent transaction references. One receiver processes two stores. The same paywall handler and receiver also run against IAPKit’s local handlers via the optional fresh-example argument to run-commerce-interop.mjs. Its actual signed Google events exercise the missing-chain account policy. Read the recorded source and reproduction instructions in paywall-provider-run.json for that separate check. Pending, canceled or failed purchases never finish; successful purchases require current product access. Use event ID deduplication in the authenticated emitter/project scope, not transaction ID deduplication. Keep unknown or inferred amounts out of known purchase totals, group currencies separately, and flag refunds/recoveries for reconciliation. The demo's gross purchase observations are not net revenue, MRR or ARPU. It extends the prior backend with AI and conversation context, not an independent one-prompt reproduction or an external product integration. The recorded replacement check at https://openiap.dev/commerce-protocol/ecosystem#composition-proof uses the same app backend and event receiver with the example and IAPKit. Read its report, configuration and limits; compatible APIs do not migrate ownership records or provision providers. The new backend build at https://openiap.dev/commerce-example/from-scratch.md starts from an independent initial commit with the exact CLI output and AI input, then adds seven implementation commits. Each commit links its code, diff, real run output and screen. The final source, first conformance failure, correction, clean-checkout replay, and intentional failing negative controls are retained. This was an iterative build by an AI with prior conversation context, not an independent model trial or one-prompt guarantee. Read the evidence's precise profile scope before reporting conformance. Its dashboard buttons run finished code; they do not generate it. The older prototype walkthrough is a separate record; do not attach the new commit history to its screenshots or claim those are the same implementation. Recorded example walkthrough: https://openiap.dev/docs/guides/ai-assistants#existing-project-example Matching source and run commands: https://openiap.dev/commerce-protocol/implementation#local-example Store sandbox and device checks: https://openiap.dev/docs/guides/testing The optional CLI requires Node.js 20+: - `npx @hyodotdev/openiap init --role app` prints an AI brief for an existing project. Other roles: experience, commerce, data. It adds a path, framework hint and guide link; it does not create code or invoke AI. Skip it when you already have the guide and project context. - `npx @hyodotdev/openiap doctor ./my-app --json` checks supported Android store settings, IAPKit keys/base URLs, env names, and React Native/Expo iOS scene declarations. Inspect each finding's id, file and fix; repair and rerun. Errors exit 1; warnings exit 0. Read notCheckedLocally even on success. The CLI reads local files; npx may download the package. Pin its version in CI. Doctor is not a general source scan, store/device test, or Commerce Protocol conformance check. Its check scope does not change with the init role. Guide: https://openiap.dev/docs/guides/ai-assistants Check reference: https://github.com/hyodotdev/openiap/tree/main/packages/cli ## Table of Contents 1. Installation 2. Core APIs (Connection, Products, Purchase, Subscription) 3. Platform-Specific APIs (iOS, Android) 4. Store Targets (Play, Horizon, Fire OS, Vega OS) 5. Types Reference 6. Error Codes & Handling 7. Implementation Patterns 8. OpenIAP Commerce Protocol ## Documentation boundary This reference documents the OpenIAP client contract and the vendor-neutral OpenIAP Commerce Protocol. IAPKit is one conforming implementation; its product setup, hosted API, compatibility, operations, MCP, and AI reference live at https://kit.openiap.dev/docs and https://kit.openiap.dev/llms.txt. --- ## 1. Installation ### React Native / Expo ```bash # expo-iap (Expo projects - recommended) npx expo install expo-iap # react-native-iap (React Native CLI) npm install react-native-iap cd ios && pod install ``` ### Swift (iOS/macOS) ```swift // Swift Package Manager .package(url: "https://github.com/hyodotdev/openiap.git", from: "4.0.9") // CocoaPods pod 'openiap', '~> 4.0.9' ``` ### Kotlin (Android) ```kotlin // app/build.gradle.kts implementation("io.github.hyochan.openiap:openiap-google:4.0.10") // settings.gradle.kts, for Meta Horizon OS and Fire OS: keep the Play coordinate; // the plugin links openiap-google-horizon / -amazon by the store rule. plugins { id("io.github.hyochan.openiap") version "4.0.10" } ``` ### Flutter ```bash flutter pub add flutter_inapp_purchase ``` ### Godot Download `godot-iap-4.3.3.zip` from GitHub Releases, extract it to `addons/godot-iap/`, then enable the plugin in Project Settings. ### Kotlin Multiplatform ```kotlin dependencies { implementation("io.github.hyochan:kmp-iap:4.2.3") } ``` Use the latest version from Maven Central: https://central.sonatype.com/artifact/io.github.hyochan/kmp-iap ### .NET MAUI ```bash dotnet add package OpenIap.Maui ``` Current NuGet package version: 3.2.3 Requires .NET 10, the MAUI workload, iOS 15.0+, and Android API 24+. --- ## Framework SDK Implementations ### react-native-iap - Package: `react-native-iap` on npm. - Implementation: Nitro Modules wrapper over `packages/apple` and `packages/google`. - Public surface: generated OpenIAP types plus `useIAP`, listener helpers, and platform-suffixed iOS/Android APIs. - Android builds resolve the store at build time: an `openiapStore` pin, the store flavor in the requested task, or on debug builds the connected device. `fireOsEnabled=true` also pins Amazon; the deprecated `horizonEnabled` is removed in the next major release. Vega OS uses a separate React Native for Vega target that resolves the `kepler` JavaScript adapter before creating the Nitro HybridObject. - Onside is not supported in `react-native-iap`; use `expo-iap` for Onside. - Example app: `libraries/react-native-iap/example`. ### expo-iap - Package: `expo-iap` on npm. - Implementation: Expo Modules wrapper over the same native OpenIAP packages. - Public surface: same hook, listener, query, mutation, and platform API shape as `react-native-iap`, adapted for Expo managed/bare workflows. - The Android store is resolved at build time: the connected device on a local debug build, `ORG_GRADLE_PROJECT_openiapStore` in the EAS profile env for EAS and release builds, which have no device to follow. `modules.amazon.fireOS` also pins Amazon, ahead of the device. The `EXPO_IAP_*` environment flags are deprecated and removed in expo-iap 7.0.0; an `app.config.js` can read the EAS profile env and set the plugin option instead. The config plugin otherwise carries store values only: `android.horizon.appId`, `android.amazon.appstoreKey`, the opt-in `modules.onside`, and optional `android.amazon.vegaOS` metadata. A root `manifest.toml` turns the Vega target on unless Fire OS is declared; `modules.amazon.vegaOS` forces it on or off. `modules.horizon` is a deprecated pin, removed in the next major release. - Example app: `libraries/expo-iap/example`. ### flutter_inapp_purchase - Package: `flutter_inapp_purchase` on pub.dev. - Implementation: Dart API plus generated `types.dart`, bridged to native iOS and Android method channels. - Public surface: singleton `FlutterInappPurchase.instance`, typed `fetchProducts`, purchase streams, and resolver-style methods. - Android builds can select Play, Horizon, or Fire OS flavors. ### godot-iap - Package: `godot-iap` for Godot 4.x. - Implementation: GDScript API with generated `types.gd`, plus native iOS GDExtension and Android AAR plugin. - Public surface: snake_case functions and Godot signals matching OpenIAP. ### kmp-iap - Package: `io.github.hyochan:kmp-iap`. - Implementation: Kotlin Multiplatform common API with Flow-based events, Android implementation, and iOS cinterop through the OpenIAP ObjC facade. - Public surface: `KmpIAP` / shared instance resolver methods and flows. ### maui-iap - Package: `OpenIap.Maui` on NuGet. - Distribution: single public NuGet package. The Android/iOS binding projects are private implementation details and are flattened into `OpenIap.Maui` instead of being published as separate package dependencies. - Implementation: .NET MAUI projection with generated `Types.cs`, a static `OpenIapClient.Instance` facade, `IOpenIap` observables, and per-platform resolvers. - iOS/macCatalyst bridge: .NET-for-iOS binding over `OpenIAP.xcframework` and `OpenIapModule+ObjC.swift`; NuGet consumers get the official `OpenIap.Maui.Bindings.iOS.resources.zip` sidecar so no app-level `NativeReference` is required. - Android bridge: Xamarin.Android binding over the MAUI-owned `openiap-release.aar`. The package carries every store's `openiap-google` AAR, and its `buildTransitive` targets link one per app build (`OpenIapStore`, else the device on a Debug build, else Play) with that store's SDK from Maven. Play Services, Gson, AndroidX, Kotlin, and kotlinx-serialization stay NuGet `PackageReference` dependencies, so every MAUI build carries them whatever the store (MAUI only). - Public surface: operations through `OpenIapClient.Query` and `OpenIapClient.Mutation` (the generated `QueryResolver` and `MutationResolver`), listener streams on `IOpenIap`, all implemented by `OpenIapIOS`, `OpenIapAndroid`, and `OpenIapMacCatalyst`; app-facing IAPKit helpers mirror the TypeScript SDKs via `OpenIapClient.KitApi(...)`. - Example app: `libraries/maui-iap/example/OpenIap.Maui.Example`, mirroring the `expo-iap` example flows. --- ## Store Setup Canonical setup docs live under `/docs/setup/store`: `/docs/setup/store/horizon`, `/docs/setup/store/amazon`, and `/docs/setup/store/onside`. Deprecated feature URLs redirect there. - Google Play: default Android artifact, `openiap-google`. - Meta Horizon: Android `horizon` flavor, `openiap-google-horizon`. Expo keeps `android.horizon.appId` in the config plugin. Expo, React Native and Flutter resolve it from `openiapStore=horizon`, an `assembleHorizon*` task, or a connected Quest on a debug build, plus app-owned manifest metadata. Native Android and KMP apps get the same rule from the `io.github.hyochan.openiap` Gradle plugin. MAUI follows a connected Quest on a Debug build, or pins `OpenIapStore=horizon`. Godot follows a connected Quest on a debug export, or pins `openiap/android_store=horizon`. Required values: Horizon app id from Meta Horizon Developer Hub (Expo: `android.horizon.appId`; Godot: the `openiap/horizon_app_id` export option; bare React Native passes a Gradle property named `horizonAppId` into manifest meta-data, and Flutter reads `HORIZON_APP_ID` from `local.properties`), product SKUs, and verification values such as `horizon.sku`, `horizon.userId`, and `horizon.accessToken` when validating Horizon purchases. - Fire OS: Android `amazon` flavor, `openiap-google-amazon`, picked by the same rule: a connected Fire device on a debug build, or `openiapStore=amazon` (Expo: in the EAS profile env). Native Android and KMP apps get the rule from the `io.github.hyochan.openiap` Gradle plugin. Runtime adapters are wired for native Android, `react-native-iap`, `expo-iap`, `flutter_inapp_purchase`, KMP, and MAUI (a connected Fire device on a Debug build, or `OpenIapStore=amazon`). Godot follows a connected Fire device on a debug export, or pins `openiap/android_store=amazon`. Required values: Android `applicationId` matching the Amazon Developer Console app, Amazon Appstore product ids / App Tester catalog entries, and the Amazon public key for Fire OS Android builds. Receipt verification and sandbox configuration belong to the chosen backend; IAPKit documents its hosted setup at https://kit.openiap.dev/docs/verification/amazon. - Vega OS: not an Android flavor. Target React Native for Vega and compatible Expo Vega targets only, using Amazon's JavaScript IAP API through the runtime-selected `kepler` adapter at the same runtime integration layer as Onside. In Expo, a root `manifest.toml` turns the Vega target on. Bare React Native Vega targets provide their own `manifest.toml`, Kepler package metadata, and runtime dependencies. A Fire OS build of the same app is a separate artifact that the Android build picks like any other store. Required values: Vega `manifest.toml` package id, title, interactive component id, Kepler runtime/module declarations, Amazon product ids, and Vega runtime dependencies. In Expo, optional `android.amazon.vegaOS` overrides (`packageId`, `title`, `appName`, `icon`) default from the normal Expo app config unless Vega metadata must differ. - Onside: currently `expo-iap` only. Enable `modules.onside=true` and run Expo prebuild so the iOS module autolinking and Podfile environment are regenerated. Required values: stable `ios.bundleIdentifier`, Onside app registration at developer.onside.io, and the `modules.onside` config flag. ### Fire OS Fire OS is an Android target for Amazon Appstore distribution. It uses the `amazon` Gradle flavor and Amazon Appstore SDK. Fire OS maps OpenIAP calls to the Amazon Appstore SDK: | OpenIAP API | Amazon Appstore SDK mapping | |-------------|--------------------------| | `initConnection()` | Register `PurchasingListener`, request user data | | `fetchProducts()` | `PurchasingService.getProductData` | | `requestPurchase()` | `PurchasingService.purchase` | | `getAvailablePurchases()` | `PurchasingService.getPurchaseUpdates(reset=true)` | | `finishTransaction()` | `PurchasingService.notifyFulfillment(..., FULFILLED)` | ### Vega OS Runtime Vega OS is not Fire OS and is not an Android build. Expo detects a Vega project from its root `manifest.toml`; the Fire OS Android artifact is picked by the store rule like any other store. Bare React Native uses the same rule for Fire OS and a separate Kepler target for Vega. Install `@amazon-devices/keplerscript-appstore-iap-lib` and let `react-native-iap` / `expo-iap` select the `kepler` adapter at runtime, similar to how Onside is selected at the runtime integration layer. --- ## Minimal Usage by Framework ### React Native / Expo ```typescript import { useEffect } from 'react'; import { Button } from 'react-native'; import { useIAP } from 'expo-iap'; // or 'react-native-iap' // verifyOnServer and grantPremium are your app's functions. function PremiumButton() { const { connected, fetchProducts, requestPurchase, finishTransaction } = useIAP({ onPurchaseSuccess: (purchase) => { void (async () => { // Verify on your backend, grant access, then finish. if (!(await verifyOnServer(purchase))) return; await grantPremium(purchase); // premium is a non-consumable; finishing must not consume it. await finishTransaction({ purchase, isConsumable: false }); })().catch((error) => { console.warn('Purchase handling failed:', error); }); }, }); useEffect(() => { if (!connected) return; void fetchProducts({ skus: ['premium'], type: 'in-app' }).catch((error) => console.warn('Product fetch failed:', error), ); }, [connected, fetchProducts]); return (