Use this page with AI

Copy this into your coding assistant and add your request.

Read https://openiap.dev/docs/getting-started and https://openiap.dev/llms.txt. Follow the reading instructions, detailed reference, and linked guides relevant to my task before making changes.
Inspect my existing project and reuse its framework and conventions. Ask me for missing product decisions. Implement the requested behavior and run the applicable checks.
Show the working result, the commands and actual test results, and any remaining limitations. Keep your explanation brief.

My request: [describe what customers should be able to do]
See an example request →

Getting Started

Add purchases to your existing app with the OpenIAP SDK for your framework. Customers can buy products, restore purchases, and use the features they paid for.

Build with AI → Give your assistant the references and a product request; review its running result. For manual integration, start with your framework’s setup guide.

  1. Choose your store, products, and what each purchase unlocks.
  2. Connect purchases to your existing login and paid features.
  3. Try buying, restoring, and canceling in the store sandbox.
Manual setup, code examples, and reference

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, test track
  • Store Setup — Horizon OS, Fire OS, Vega OS, and alternative marketplaces

2. Pick a framework#

Use your app’s existing framework. SDKs share the purchase contract; types and lifecycle patterns follow each language.

3. Your first purchase flow#

Connect, load products, listen for results, then request a purchase. The examples below outline that flow; add your backend verification and access logic. 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#

References for choosing an SDK and managing the purchase lifecycle:

  • 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 after verification and delivery.

5. How the docs are organized#

Use a feature guide for a complete flow, APIs for calls, and Types for data fields.

6. Where to go next#