Docs › SDKs
Android SDK
Google Play Billing 8, Kotlin coroutines, Jetpack Compose paywalls. minSdk 23.
Install
Copy the appwind-purchases module into your project:
// settings.gradle.kts
include(":appwind-purchases")
// app/build.gradle.kts
implementation(project(":appwind-purchases"))
Configure
class App : Application() {
override fun onCreate() {
super.onCreate()
Purchases.configure(this, apiKey = "goog_…", server = "https://pay-api.appwind.ai",
fallbackServers = listOf("https://pay-api2.appwind.ai")) // optional
}
}
Use
Purchases.shared.logIn("user_42")
val info = Purchases.shared.customerInfo()
if (info.entitlements["pro"]?.isActive == true) unlock()
Purchases.shared.customerInfoFlow.collect { info -> … }
val offerings = Purchases.shared.offerings()
val yearly = offerings.current!!.packages.first { it.identifier == "\$rc_annual" }
val result = Purchases.shared.purchase(activity, yearly)
Purchases.shared.restorePurchases()
PaywallScreen(activity, onClose = { … }, onPurchased = { … }, customVariables = mapOf("name" to name))
FlowScreen(activity, placement = "onboarding", onFinish = { … })
Things the SDK takes care of
- Sets
obfuscatedAccountIdso Google's notifications reach the right user. - Pending purchases (cash, slow cards) grant nothing until paid.
- Purchases are queued and re-sent until Appwind Pay confirms; if Appwind Pay can't be reached for 2 days the SDK acknowledges the purchase itself so Google doesn't refund it.
- Reconnects to Google Play Billing when the connection drops.
- Keeps the last offerings and paywall for offline use; tries backup servers.