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 Real-time Developer Notifications to a Pub/Sub topic for supported lifecycle events. CashSDK also polls voided purchases for refund and revocation coverage; do not rely on RTDN alone for every refund.

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#

For the illustrated, one-step-at-a-time flow, open Quickstart → Android and follow the dashboard walkthrough.

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. You do not need to grant the service account a Google Cloud IAM role.

2
Grant it Play access

In the Play Console, go to Users and permissions → Invite new users and enter the service account's email. Leave Set access expiry date unticked.

On the App permissions tab (not Account permissions), click Add app and choose your app. In the permissions dialog:

  • Under App access, tick View app information (read-only). It is required: Apply stays disabled until an App access box is ticked. View app quality information ticks itself.
  • Under Financial data, tick View financial data and Manage orders and subscriptions.

Click Apply, then Invite user, then Send invite in the confirmation. When editing an existing user, click Apply, then Save changes. A new grant can take a few minutes to reach Google's API.

3
Add it to CashSDK

In your dashboard, open Quickstart → Android → Select your JSON key (or Store Connect → Google Play), select the service-account JSON, and enter your app's package name (for example com.acme.app). In Quickstart, each input is a separate step; the key is uploaded at Validate your Play connection. It 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 Quickstart → Android → Set the Play notification topic and Store Connect. 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 Play Console under Settings → License testing, add the Google accounts that should make test purchases. For the internal-track workflow, also add them as track testers, have them opt in, and install that build. Google also supports sideloading for license testers with the matching package name.

2
Run a purchase as a licence tester

Configure the SDK with your csk_pk_… key, the same key you ship. Licence testers can choose test payment instruments without real charges. Check that checkout shows a test instrument; joining an internal track alone does not make purchases free. Test renewals run on an accelerated clock.

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#