Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

kmp-iap

kmp-iap logo

Maven Central Java CI with Gradle OpenIAP Compliant Coverage Status License

A comprehensive Kotlin Multiplatform library for in-app purchases on Android and iOS platforms that conforms to the Open IAP specification

Open IAP

📚 Documentation

Visit the documentation site for installation guides, API reference, and examples:

Using with AI Assistants

kmp-iap provides AI-friendly documentation for Cursor, GitHub Copilot, Claude, and ChatGPT.

📖 AI Assistants Guide →

Quick links:

📦 Installation

dependencies {
    implementation("io.github.hyochan:kmp-iap:1.3.8")
}

🚀 Quick Start

Option 1: Using Global Instance (Simple)

import io.github.hyochan.kmpiap.kmpIapInstance
import io.github.hyochan.kmpiap.*

// Use the global singleton instance
kmpIapInstance.initConnection()

// Get products - DSL API in v1.0.0-rc.2
val products = kmpIapInstance.fetchProducts {
    skus = listOf("product_id")
    type = ProductQueryType.InApp
}

// Request purchase - DSL API with platform-specific options
val purchase = kmpIapInstance.requestPurchase {
    ios {
        sku = "product_id"
        quantity = 1
    }
    android {
        skus = listOf("product_id")
    }
}

// Or just for one platform
val iosPurchase = kmpIapInstance.requestPurchase {
    ios {
        sku = "product_id"
    }
}

// Finish transaction (after server-side validation)
kmpIapInstance.finishTransaction(
    purchase = purchase.toPurchaseInput(),
    isConsumable = true // true for consumables, false for subscriptions
)

Option 2: Create Your Own Instance (Recommended for Testing)

import io.github.hyochan.kmpiap.KmpIAP
import io.github.hyochan.kmpiap.*

// Create your own instance
val kmpIAP = KmpIAP()

// Initialize connection
kmpIAP.initConnection()

// Get products - DSL API in v1.0.0-rc.2
val products = kmpIAP.fetchProducts {
    skus = listOf("product_id")
    type = ProductQueryType.InApp
}

// Request purchase - DSL API with platform-specific options
val purchase = kmpIAP.requestPurchase {
    ios {
        sku = "product_id"
        quantity = 1
    }
    android {
        skus = listOf("product_id")
    }
}

// Or just for one platform
val androidPurchase = kmpIAP.requestPurchase {
    android {
        skus = listOf("product_id")
    }
}

// Finish transaction (after server-side validation)
kmpIAP.finishTransaction(
    purchase = purchase.toPurchaseInput(),
    isConsumable = true // true for consumables, false for subscriptions
)

Powered by OpenIAP

OpenIAP

kmp-iap conforms to the OpenIAP specification — an open, vendor-neutral interoperability standard for in-app purchases. OpenIAP provides:

  • Shared specification — Common types, error codes, and purchase flows across all platforms
  • Generated type-safe bindings — Swift, Kotlin, Dart, and GDScript from a single GraphQL schema
  • Platform implementationsopeniap-apple (StoreKit 2) and openiap-google (Play Billing 8.x)
  • Verification profiles — Standardized receipt validation and purchase verification patterns

Other libraries built on OpenIAP: react-native-iap · expo-iap · flutter_inapp_purchase · godot-iap

Learn more about the OpenIAP standard →

📄 License

MIT License - see LICENSE file for details.