Getting Started
OpenIAP is a unified spec for in-app purchases on Apple, Google Play, Meta Horizon, and Amazon Appstore targets. One GraphQL schema generates type-safe SDKs for TypeScript, Swift, Kotlin, Dart, C#, and GDScript — so the same purchase flow works across every framework you ship in.
This page is a five-minute walkthrough. If you'd rather jump straight into your stack, head to Framework Setup.
1. Configure the store#
Every framework wraps the same store APIs, so the platform setup comes first. Finish these before installing any SDK:
- iOS Setup — App Store Connect agreement, capability, sandbox testers
- Android Setup — Play Console account, license testers, billing permission
- Store Setup — Horizon OS, Fire OS, Vega OS, and alternative marketplaces
2. Pick a framework#
OpenIAP ships official SDKs for six frameworks. Pick the one your app uses — the API surface is identical across all of them.
- expo-iap — Expo SDK projects
- react-native-iap — bare React Native CLI projects (RN 0.79+)
- flutter_inapp_purchase — Flutter / Dart
- kmp-iap — Kotlin Multiplatform / Compose Multiplatform
- maui-iap — .NET MAUI / C#
- godot-iap — Godot 4.x
3. Your first purchase flow#
The four-step flow below is the same on every framework — only the imports differ. Read Features → Purchase for a full walkthrough with verification, error handling, and consumable/non-consumable nuances.
import OpenIap
let store = OpenIapModule.shared
// 1. Open the store connection on app start.
let connected = try await store.initConnection()
precondition(connected, "Store connection failed")
// 2. Fetch products by SKU.
let products = try await store.fetchProducts(
ProductRequest(skus: ["com.app.premium"], type: .inApp)
)
// 3. Listen for purchase results — requestPurchase is event-based.
// Keep this token alive for as long as purchases should be observed.
let purchaseSubscription = store.purchaseUpdatedListener { purchase in
Task {
// Verify on your backend, grant entitlement, then finish.
do {
try await store.finishTransaction(
purchase: purchase,
isConsumable: false
)
} catch {
print("Failed to finish transaction: (error)")
}
}
}
// On app shutdown:
// store.removeListener(purchaseSubscription)
// 4. Initiate a purchase.
try await store.requestPurchase(
RequestPurchaseProps(
request: .purchase(RequestPurchasePropsByPlatforms(
apple: RequestPurchaseIosProps(sku: "com.app.premium")
)),
type: .inApp
)
)4. Key concepts#
Two background reads make every framework guide easier to follow — skim them before you wire anything into production.
- Ecosystem — how OpenIAP, the native packages (Apple / Google), and each framework SDK fit together. Read this first if you're choosing a stack.
- Life Cycle — when to call
initConnection, where to mount listeners, and when to callfinishTransaction. Getting this wrong is the #1 cause of "purchase succeeded but the user didn't get the entitlement" reports, so read it once even if you skip everything else.
5. How the docs are organized#
The sidebar groups content by intent. Once you know which group fits the question you're answering, navigation becomes muscle memory.
- Setup Guide — install + native config per framework (Expo, React Native, Flutter, Kotlin Multiplatform, .NET MAUI, Godot) plus the store-side configuration (iOS, Android, store setup).
- Features — task-oriented walkthroughs, not reference. Each page covers a real flow end-to-end (Purchase, Subscription, Refund, Validation, Offer Code Redemption, …) with verification, edge cases, and platform notes. Open a Features page when you're shipping a flow, not just calling a function.
- APIs — flat reference, one page per function (
initConnection,fetchProducts,requestPurchase, …). Cross-platform symbols live at the root; iOS- and Android-only symbols are grouped under iOS Specific / Android Specific. Open a function page when you need its exact signature, params, and a copy-pasteable example. - Types — flat reference, one page per type (
Product,Purchase,RequestPurchaseProps, …). Same iOS / Android grouping as APIs. Field tables auto-link to related types so you can chase a shape without leaving the docs. - Events & Errors — listener patterns and the unified
PurchaseErrorcodes that every SDK normalizes to.
Rule of thumb: "How does this function work?" → APIs. "What does this object look like?" → Types. "How do I ship subscription upgrades?" → Features.
6. Where to go next#
- Purchase, Subscription, Refund — full feature walkthroughs
- Validation — server-side verification (your own backend or IAPKit — open source under MIT, with hosted validation and analytics free at kit.openiap.dev or self-host from
packages/kit) - API Reference — every function with cross-platform signatures
- Types — every type with field tables
- Errors — unified
PurchaseErrorcodes