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#

1
Play Billing runs the purchase

The Android SDK presents the offering and drives Play's native purchase flow, which returns a purchase token.

2
CashSDK verifies it server-side

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.

3
RTDN keeps it current

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.

1
Create a service account

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.

2
Grant it Play access

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.

3
Add it to CashSDK

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.

4
Turn on Real-time Developer Notifications

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.

Create your products#

1
Create products in the Play Console

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.

2
Map them to entitlements in CashSDK

Create a matching product in CashSDK with the same identifier and attach the entitlement it unlocks. Or import the catalog automatically:

bash
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.

kotlin
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#

1
Add license testers

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).

2
Run a purchase as a licence tester

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.

3
Confirm entitlements and RTDN

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.

Next steps#