Built on Play Billing v7. Purchases are validated server-side, so entitlements remain trustworthy independent of the client.
Android SDK
Add in-app purchases and paywalls to your Android app with Kotlin and Play Billing.
The CashSDK Android SDK wraps Play Billing in idiomatic Kotlin. Its suspend
functions plug straight into coroutines, so fetching offerings, running
purchases, and reading entitlements are all ordinary await-style calls.
Install#
Add the dependency to your module's build.gradle.kts:
dependencies {
implementation("com.cashsdk:cashsdk-android:1.0.0")
}
The SDK is published to Maven Central, so no extra repositories are required.
Configure#
Initialize CashSDK once in your Application.onCreate with your publishable
key. This guarantees it is ready before any activity runs.
import android.app.Application
import com.cashsdk.CashSDK
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
CashSDK.configure(apiKey = "pk_live_...")
}
}
Register the class in your manifest:
<application
android:name=".MyApp"
... >
Ship only publishable keys (pk_live_… / pk_test_…) in your app. Secret keys
(csk_sk_…) belong on your backend.
Fetch offerings#
offerings() is a suspend function — call it from a coroutine scope, such as
viewModelScope or lifecycleScope.
val offering = CashSDK.offerings()
val monthly = offering.monthly
val annual = offering.annual
Purchase#
Pass a package to purchase. CashSDK drives the Play Billing flow, validates the
purchase token, and returns the customer's updated entitlements.
lifecycleScope.launch {
val result = CashSDK.purchase(offering.monthly)
if (result.entitlements["pro"]?.isActive == true) {
unlockPro()
}
}
Check entitlements#
Read entitlements from any purchase or restore result to gate features.
if (result.entitlements["pro"]?.isActive == true) {
// Show premium content
} else {
// Show the paywall
}
Restore purchases#
Let customers recover access on a new device or after reinstalling.
val result = CashSDK.restorePurchases()
if (result.entitlements["pro"]?.isActive == true) {
unlockPro()
}
Identify the customer#
Link the SDK to your own user ID so entitlements sync across devices and
platforms. Call identify once the user is signed in.
CashSDK.identify("u_812")
ProGuard / R8#
The published artifact ships with consumer ProGuard rules, so entitlement and result models survive R8 shrinking without configuration. If you run an aggressive custom setup, keep the SDK's public types:
-keep class com.cashsdk.** { *; }