https://github.com/hyochan/kmp-iap
In App Purchase module in Kotlin Multi Platform
https://github.com/hyochan/kmp-iap
compose-multiplatform compose-multiplatform-library iap inapppurchase kotlin multiplatform open-iap openiap
Last synced: 5 months ago
JSON representation
In App Purchase module in Kotlin Multi Platform
- Host: GitHub
- URL: https://github.com/hyochan/kmp-iap
- Owner: hyochan
- License: apache-2.0
- Created: 2025-07-10T09:57:11.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-01-17T01:23:24.000Z (5 months ago)
- Last Synced: 2026-01-17T11:42:29.485Z (5 months ago)
- Topics: compose-multiplatform, compose-multiplatform-library, iap, inapppurchase, kotlin, multiplatform, open-iap, openiap
- Language: Kotlin
- Homepage: https://hyochan.github.io/kmp-iap
- Size: 8.06 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# kmp-iap
A comprehensive Kotlin Multiplatform library for in-app purchases on Android and iOS platforms that conforms to the Open IAP specification
## 📚 Documentation
Visit the documentation site for installation guides, API reference, and examples:
### **[hyochan.github.io/kmp-iap](https://hyochan.github.io/kmp-iap)**
## Using with AI Assistants
kmp-iap provides AI-friendly documentation for Cursor, GitHub Copilot, Claude, and ChatGPT.
**[📖 AI Assistants Guide →](https://hyochan.github.io/kmp-iap/docs/guides/ai-assistants)**
Quick links:
- [llms.txt](https://hyochan.github.io/kmp-iap/llms.txt) - Quick reference (~300 lines)
- [llms-full.txt](https://hyochan.github.io/kmp-iap/llms-full.txt) - Full API reference (~1000 lines)
## 📦 Installation
```kotlin
dependencies {
implementation("io.github.hyochan:kmp-iap:1.3.5")
}
```
## 🚀 Quick Start
### Option 1: Using Global Instance (Simple)
```kotlin
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)
```kotlin
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
)
```
## 📄 License
MIT License - see [LICENSE](LICENSE) file for details.