Skip to main content
Version: v1.0.0-rc (Current)

🛒 kmp-iap

Version

This documentation is for kmp-iap v1.0.0-rc with simplified API design.

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

kmp-iap Logo

🚀 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

FeatureiOSAndroid
Products & Subscriptions
Purchase Flow
Receipt Validation
Subscription Management
Promotional OffersN/A
StoreKit 2N/A
Billing Client v8N/A

🔄 Version Information

  • Current Version: 1.0.0-rc
  • Kotlin Compatibility: Kotlin 2.1.10+
  • iOS Requirements: iOS 11.0+
  • Android Requirements: API level 24+

⚡ Quick Start

Get started with kmp-iap in minutes:

// In your build.gradle.kts
dependencies {
implementation("io.github.hyochan:kmp-iap:1.0.0-rc.2")
}

Option 1: Using Global Instance (Simple)

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

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

// Get products
val products = kmpIapInstance.requestProducts(
ProductRequest(
skus = listOf("product_id"),
type = ProductType.INAPP
)
)

// Request purchase
val purchase = kmpIapInstance.requestPurchase(
UnifiedPurchaseRequest(
sku = "product_id",
quantity = 1
)
)

// Finish transaction after validation
kmpIapInstance.finishTransaction(purchase, isConsumable = true)
import io.github.hyochan.kmpiap.KmpIAP
import io.github.hyochan.kmpiap.types.*

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

// Initialize connection
kmpIAP.initConnection()

// Get products
val products = kmpIAP.requestProducts(
ProductRequest(
skus = listOf("product_id"),
type = ProductType.INAPP
)
)

// Request purchase
val purchase = kmpIAP.requestPurchase(
UnifiedPurchaseRequest(
sku = "product_id",
quantity = 1
)
)

// Finish transaction after validation
kmpIAP.finishTransaction(purchase, isConsumable = true)

🚀 Start Building Today

🤝 Community & Support

This project is maintained by hyochan.


Ready to implement in-app purchases in your Kotlin Multiplatform app? Let's get started! 🚀