Built on Play Billing v9. A purchase token is never trusted on-device: it is verified server-side, and consumable products are consumed (not just acknowledged) so a customer can buy them again. Unacknowledged purchases are auto-refunded by Google after three days. CashSDK acknowledges on your behalf the moment it verifies.
Google Play
Connect Google Play so Play Billing purchases and subscriptions are verified server-side and resolve to CashSDK entitlements.
Google Play Billing is the billing rail for in-app purchases and subscriptions on Android. CashSDK verifies every Play purchase token against the Google Play Developer API on your server, and ingests Real-time Developer Notifications (RTDN) for renewals, cancellations, and refunds, so Android entitlements are exactly as authoritative as iOS, and roll up into the same analytics.
How it works#
The Android SDK presents the offering and drives Play's native purchase flow, which returns a purchase token.
The SDK forwards the token to CashSDK, which calls the Play Developer API to confirm the purchase, then acknowledges or consumes it before granting an entitlement.
Google publishes a Real-time Developer Notification to a Pub/Sub topic for every renewal, cancellation, grace period, and refund. CashSDK subscribes to that topic and keeps entitlements current for the whole lifecycle.
Prerequisites#
- A Google Play Console account with your app published to at least an internal testing track.
- Admin (or owner) access to the Play Console, so you can grant API access.
- A Google Cloud project where you can create a service account and enable the Play Developer API.
Connect Google Play#
CashSDK talks to Google with a service account that has access to your Play Developer account. This lets it verify purchase tokens and read subscription state.
In the Google Cloud console, create a service account and generate a JSON key. In APIs & Services, enable the Google Play Android Developer API for the project.
In the Play Console, go to Users and permissions → Invite new users, add the service account's email, and grant it access to view financial data and manage orders and subscriptions for your app.
In your dashboard, open Settings → Billing → Google Play, upload the
service-account JSON, and enter your app's package name (for example
com.acme.app). The key is stored encrypted at rest and never ships in your
app.
CashSDK provisions a dedicated Pub/Sub topic for your app and shows its name in Settings → Billing → Google Play. Copy it into the Play Console under Monetization setup → Real-time developer notifications, paste the Topic name, and click Send test notification to confirm the link.
The CashSDK onboarding wizard and the MCP server can provision the Pub/Sub topic and validate the service account for you, so you only paste the topic name into the Play Console.
Create your products#
Under Monetization → Subscriptions (or In-app products), create each
product with a Product ID (for example pro_monthly) and define its
base plans and offers.
Create a matching product in CashSDK with the same identifier and attach the entitlement it unlocks. Or import the catalog automatically:
sync_catalog_from_app_store(store="play-store", dryRun=true)
Run it without dryRun to import your Play products as CashSDK products.
Integrate the SDK#
With the catalog mapped, the Android SDK handles offerings, purchase, verification, acknowledgement, and entitlements for you.
import com.cashsdk.CashSDK
CashSDK.configure(context = this, publishableKey = "csk_pk_…")
val entitlements = CashSDK.shared.purchase(activity, "pro_monthly")
val result = CashSDK.purchase(offering.monthly)
if (entitlements.isActive("pro")) unlockPro()
Test on a testing track#
In the Play Console under Setup → License testing, add the Google accounts that should make test purchases. Testers must install your app from a testing track (internal, closed, or open).
Configure the SDK with your csk_pk_… key, the same key you ship. Licence
testers are charged a
test amount that is auto-refunded, and Google's test renewals run on an
accelerated clock so you can watch renewals and cancellations quickly.
Verify the purchase grants pro, then watch Events in your dashboard for
purchase.completed and, on renewal, subscription.renewed, driven by the
incoming RTDN.
A purchase must be verified before it is acknowledged within three days, or Google refunds it automatically. Letting the SDK verify (rather than acknowledging in your own app code) guarantees this happens. See Testing.
Go live#
Before you ship:
- The service account has financial data and order management access.
- RTDN is enabled with the CashSDK Pub/Sub topic, and the test notification arrived.
- Products are active on a production track.
The dashboard's setup checklist (get_setup_checklist) turns green when each of
these is satisfied.