Android implementation of the OpenIAP specification using Google Play Billing.
Modern Android Kotlin library for in-app purchases using Google Play Billing Library v9.1.
Visit openiap.dev for complete documentation, API reference, guides, and examples.
- Google Play Billing v9.1
- Kotlin Coroutines
- Type-safe API with sealed classes
- Real-time purchase events
- Thread-safe operations
- Comprehensive error handling
- Minimum SDK: 23 (Android 6.0)
- Compile SDK: 36
- Google Play Billing: v9.1.0
- Kotlin compiler (consumer): 2.1.20+
Add to your module's build.gradle.kts:
dependencies {
implementation("io.github.hyochan.openiap:openiap-google:<version>")
}Use the latest version from Maven Central or the badge above.
To ship to Meta Quest or Fire OS as well, apply the OpenIAP Gradle plugin in
settings.gradle.kts and keep the dependency above. It links the Horizon or
Amazon build for a debug build on a Quest or Fire device, and for any build that
sets openiapStore:
// settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("io.github.hyochan.openiap") version "<version>"
}See Store Setup for the full rule.
import dev.hyo.openiap.store.OpenIapStore
class MainActivity : AppCompatActivity() {
private lateinit var iapStore: OpenIapStore
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
iapStore = OpenIapStore(this)
lifecycleScope.launch {
// Initialize connection
iapStore.initConnection()
// Fetch products
val products = iapStore.fetchProducts(
ProductRequest(skus = listOf("premium_upgrade"))
)
}
}
}For detailed usage, see the documentation.
Run the included sample app:
cd packages/google
./gradlew :Example:installPlayDebugThe store flavor comes from the task name, so installPlayDebug,
installAmazonDebug, and installHorizonDebug each build against their own
billing SDK.
Set these in packages/google/local.properties (untracked) or pass them as
Gradle properties:
| Property | Gradle property | Purpose |
|---|---|---|
iapkit.api.key |
IAPKIT_API_KEY |
openiap-kit_pk_ publishable key, never an sk_ key. |
iapkit.base.url |
IAPKIT_BASE_URL |
Origin of a local IAPKit server; empty uses the host. |
amazon.rvs.sandbox |
AMAZON_RVS_SANDBOX |
true for Amazon App Tester receipts. |
iapkit.base.url is an origin, not the verify path. For Local (IAPKit) the
key and the local server must target the same Convex deployment. An Android
device on USB reaches the host through adb reverse: inspect
adb -s "$ANDROID_SERIAL" reverse --list, reuse an exact tcp:3100 mapping
when one exists, or create it with
adb -s "$ANDROID_SERIAL" reverse --no-rebind tcp:3100 tcp:3100, then use
http://127.0.0.1:3100. Debug builds permit cleartext to loopback only; release
builds keep the platform default.
The purchase and subscription screens list verification in this order:
- None (Skip) — skip verification.
- Local (Device) — trust the store's own purchase state on the device.
- Local (IAPKit) — IAPKit provider routed to
iapkit.base.url. - IAPKit — hosted IAPKit; the local URL is deliberately omitted.
With both values configured, the example defaults to Local (IAPKit). With only the key, it defaults to hosted IAPKit; without a key, it defaults to None (Skip).
Thank you to Meta and Amazon Developer for supporting OpenIAP. View sponsorship options.
We also recognize sponsors and backers through OpenCollective. The original react-native-iap collective now supports the broader OpenIAP ecosystem and is managed separately from the main sponsor program.
Become a sponsor | Become a backer
Supported the project before the OpenIAP sponsor program.
MIT License - see LICENSE for details.