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.

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.

swift
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 call finishTransaction. 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.

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#