Add the PurchaseKit library to your Android app and register the bridge component.
Add JitPack to your project's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add PurchaseKit to your app's build.gradle.kts:
dependencies {
implementation("com.github.purchasekit:purchasekit-android:0.1.0")
}
In your Application class, register the PaywallComponent:
import android.app.Application
import dev.hotwire.core.bridge.BridgeComponentFactory
import dev.hotwire.core.bridge.KotlinXJsonConverter
import dev.hotwire.core.config.Hotwire
import dev.hotwire.navigation.config.registerBridgeComponents
import dev.purchasekit.android.PaywallComponent
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Hotwire.registerBridgeComponents(
BridgeComponentFactory("paywall", ::PaywallComponent)
)
Hotwire.config.jsonConverter = KotlinXJsonConverter()
}
}
The component name "paywall" must match the name used in your web app's JavaScript.
When your web paywall loads, it sends a prices message to the native app. PurchaseKit fetches localized prices from Google Play and returns them to the web.
When the user taps Subscribe, your web app sends a purchase message with:
- googleStoreProductId - The product ID from Google Play Console
- correlationId - A UUID that links this purchase to your PurchaseKit Purchase Intent
PurchaseKit launches the Google Play purchase flow and returns the result.
Add your test accounts to Play Console → Setup → License testing. License testers can make purchases without being charged.
For full end-to-end testing:
Create your subscriptions in Google Play Console.