🛒 kmp-iap
This documentation is for kmp-iap v1.2.0 which includes Google Play Billing 8.2.0 features: Billing Programs API and one-time product discounts. Native code is powered by openiap-google and openiap-apple modules.
A comprehensive Kotlin Multiplatform library for in-app purchases on iOS and Android that conforms to the Open IAP specification.

🚀 What is kmp-iap?
This is an In App Purchase library for Kotlin Multiplatform. This project has been inspired by flutter_inapp_purchase and react-native-iap. We are trying to share same experience of in-app-purchase in Kotlin Multiplatform as in Flutter and React Native.
We will keep working on it as time goes by just like we did in flutter_inapp_purchase and react-native-iap.
✨ Key Features
- Kotlin Multiplatform: Share IAP logic across iOS and Android
- StoreKit 2 Support: Full StoreKit 2 support for iOS 15.0+ with automatic fallback
- Billing Client v8: Latest Android Billing Client features
- Type-safe: Complete type safety with Kotlin's strong typing
- Coroutines Support: Modern async/await pattern with Kotlin Coroutines
- StateFlow Integration: Reactive state management with StateFlow
- Receipt Validation: Built-in receipt validation for both platforms
🎯 What this library does
- Product Management: Fetch and manage consumable and non-consumable products
- Purchase Flow: Handle complete purchase workflows with proper error handling
- Subscription Support: Full subscription lifecycle management
- Receipt Validation: Validate purchases on both platforms
- Store Communication: Direct communication with App Store and Google Play
- Error Recovery: Comprehensive error handling and recovery mechanisms
🛠️ Platform Support
| Feature | iOS | Android |
|---|---|---|
| Products & Subscriptions | ✅ | ✅ |
| Purchase Flow | ✅ | ✅ |
| Receipt Validation | ✅ | ✅ |
| Subscription Management | ✅ | ✅ |
| Promotional Offers | ✅ | N/A |
| StoreKit 2 | ✅ | N/A |
| Billing Client v8 | N/A | ✅ |
🔄 Version Information
- Current Version: 1.2.0
- Kotlin Compatibility: Kotlin 2.1.10+
- iOS Requirements: iOS 15.0+ (via openiap-apple)
- Android Requirements: API level 24+ (via openiap-google)
⚡ Quick Start
Get started with kmp-iap in minutes:
// In your build.gradle.kts
dependencies {
implementation("io.github.hyochan:kmp-iap:1.2.2")
}
Option 1: Using Global Instance (Simple)
import io.github.hyochan.kmpiap.kmpIapInstance
import io.github.hyochan.kmpiap.*
// Initialize connection
kmpIapInstance.initConnection()
// Get products using DSL
val products = kmpIapInstance.fetchProducts {
skus = listOf("product_id")
type = ProductQueryType.InApp
}
// Request purchase using DSL
val purchase = kmpIapInstance.requestPurchase {
ios {
sku = "product_id"
quantity = 1
}
android {
skus = listOf("product_id")
}
}
// Finish transaction after validation
kmpIapInstance.finishTransaction(
purchase = purchase.toPurchaseInput(),
isConsumable = true
)
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 using DSL
val products = kmpIAP.fetchProducts {
skus = listOf("product_id")
type = ProductQueryType.InApp
}
// Request purchase using DSL
val purchase = kmpIAP.requestPurchase {
ios {
sku = "product_id"
quantity = 1
}
android {
skus = listOf("product_id")
}
}
// Finish transaction after validation
kmpIAP.finishTransaction(
purchase = purchase.toPurchaseInput(),
isConsumable = true
)
🚀 Start Building Today
🤝 Community & Support
This project is maintained by hyochan.
- GitHub Issues: Report bugs and feature requests
- Discussions: Join community discussions
- Contributing: Contribute to the project
Ready to implement in-app purchases in your Kotlin Multiplatform app? Let's get started! 🚀
