Google Play
Invite a billing service account in Play Console, set up real-time developer notifications through an authenticated Pub/Sub push subscription, and connect both to AppCore.
On this page
AppCore verifies Android purchases and subscriptions with Google and turns them into entitlements:
- The app buys through Play Billing and sends the purchase token to
POST /v1/commerce/purchases/verify. AppCore reads the current state from the Google Play Developer API with a service account you invite into Play Console, grants the entitlement, and only then acknowledges (or consumes) the purchase. - Google sends lifecycle events as real-time developer notifications (RTDN) to a Pub/Sub topic. A Pub/Sub push subscription with OIDC authentication delivers them to AppCore. AppCore checks the token on every request and then re-reads the purchase from the Play API; the notification body alone never changes state.
- A scheduled sweep reads voided purchases (refunds, chargebacks); no setup is needed.
Google is the merchant of record for Play sales. See Stores as merchant of record. Pub/Sub is a Google transport required by RTDN; it is the one non-Cloudflare piece of this integration. Console paths are as of 2026-11.
Note
Verification, acknowledgement, RTDN, refunds and reconciliation are implemented and tested in the Workers runtime
against fake Play Developer and Pub/Sub APIs. They have not yet run against a real Play account (PROVIDER_TESTED
is pending real credentials).
Warning
Not yet enabled:
- Keyless (federated) credentials.
credential_modemust beservice_account_key. - Automatic product sync from Play Console. Map product IDs by hand in Store mappings.
- Purchase prices in revenue reports. Store purchases are counted as unpriced until purchase events carry amounts.
Before you begin
- Play Console Admin on the developer account, and the app created in Play Console with this environment's package name.
- A Google Cloud project you will use for billing access and Pub/Sub, with Owner or Editor on it, and Service Account Key Admin to create keys.
- Your environment's API host,
https://<your-api-host>.
Steps
1. Billing access
Enable the API. Google Cloud console → your project → APIs & Services → Library → Google Play Android Developer API → Enable.
Create the billing service account. IAM & Admin → Service Accounts → Create service account, for example
appcore-play-billing. It needs no project role for the Play API.Create its key. Open it → Keys → Add key → Create new key → JSON. The file downloads once.
Invite it into Play Console. Play Console → Users and permissions → Invite new users. Enter the service account's email. On App permissions, add your app and grant:
- View app information (read-only)
- View financial data, orders, and cancellation survey responses
- Manage orders and subscriptions
Send the invitation. Service accounts do not need to accept it.
2. Real-time developer notifications
Create the topic. Google Cloud console → Pub/Sub → Topics → Create topic, for example
play-rtdn-<app>-staging. Its full name isprojects/<project-id>/topics/<topic>.Let Play publish. On the topic → Permissions → Add principal:
google-play-developer-notifications@system.gserviceaccount.com, role Pub/Sub Publisher.Create the push identity. A second service account, for example
appcore-rtdn-push, used only to sign push requests. Keep it separate from the billing account. On it, grant the Pub/Sub service agent (service-<project-number>@gcp-sa-pubsub.iam.gserviceaccount.com) the role Service Account Token Creator.Create the connection in AppCore first, so you have its URL: Setup and connections → Connections → Google Play purchases, subscriptions and RTDN. Save the public fields you have, then copy the Callback URL:
Codehttps://<your-api-host>/webhooks/google-play/<connection-id>Create the push subscription. Pub/Sub → Subscriptions → Create subscription:
- Topic: your RTDN topic.
- Delivery type: Push. Endpoint URL: the Callback URL.
- Tick Enable authentication. Service account: the push identity from step 3. Audience: the same Callback URL, exactly.
- Acknowledgement deadline: 60 seconds. Retry policy: exponential backoff. A dead-letter topic is optional.
Let AppCore verify the setup. On the topic and on the subscription → Permissions → Add principal: the billing service account, role Pub/Sub Viewer. Without this the read-only check cannot confirm the push configuration and the connection cannot be activated.
Turn on RTDN in Play. Play Console → your app → Monetize with Play → Monetization setup → Real-time developer notifications: paste the full topic name and save.
3. Finish the connection
- Fill in every field below and paste the billing service account's JSON key into
service_account_key_json. Delete the local file. - Run Check syntax, then Read-only check, then Activate.
- In Play Console, press Send test notification on the RTDN page. AppCore stores it with outcome
testand grants nothing. Record the Pub/Sub message ID as evidence forplay-rtdn-test. - Products: Monetize with Play → Products → In-app products or Subscriptions (with base plans and offers). IDs must match what you map in Products and entitlements → Store mappings.
- Testers: Play Console (all apps) → Settings → License testing: add tester Google accounts, and distribute the build through an internal testing track.
- Buy in the app with the SDK (Getting started, step 7).
IapStoreBridgesets Play'sobfuscatedAccountIdto the purchase intent's account binding. Record the order ID as evidence forplay-sandbox-purchase, and attestplay-negativeafter checking that a push without a valid token is rejected.
Paste into AppCore
| AppCore field | Where to find it | Secret? |
|---|---|---|
package_name | Play Console → All apps → your app → package name under the title | Public |
developer_account_ref | The number in the Play Console URL: play.google.com/console/u/0/developers/<this number>/… | Public |
cloud_project_id | Google Cloud console → project picker → Project ID | Public |
service_account_email | IAM & Admin → Service Accounts → billing account → Email | Public |
credential_mode | service_account_key | Public |
service_account_key_json | The billing account's JSON key file, whole contents | Secret (write-only) |
rtdn_topic | Pub/Sub → Topics → full name projects/<project-id>/topics/<topic> | Public |
push_subscription | Pub/Sub → Subscriptions → subscription ID (or full projects/<project-id>/subscriptions/<id>) | Public |
push_service_account_email | The push identity's email (step 2.3) | Public |
push_token_audience | The Callback URL, exactly as entered as the subscription's Audience | Public |
refund_capability_enabled | true only if operators may refund through the Play API | Public |
federation_configuration | Leave empty (not used) | Public |
catalog_mapping_version | Filled by the platform from your published store mappings | Public |
Paste into Google Cloud: the connection's Callback URL as the push Endpoint URL and as the Audience.
Verify
The Read-only check sends nothing and changes nothing. It passes with PLAY_API_READABLE and
PUBSUB_PUSH_CONFIG_OK when:
- the billing account can read
purchases/voidedpurchasesfor your package (this needs View financial data); - the subscription is attached to
rtdn_topic, is a push subscription, delivers to exactly this connection's Callback URL, authenticates aspush_service_account_emailwith audiencepush_token_audience; - the topic grants Play's publisher account Pub/Sub Publisher.
Then:
- After Activate,
google_playappears inpurchase_providersofGET https://<your-api-host>/v1/config/public. - The Play test notification is processed with outcome
test. - A licence-tester purchase appears in Purchases and finance → Purchases. Development and staging accept only test purchases; production rejects them, and test environments reject real ones.
- With every sandbox check evidenced the connection becomes
sandbox_ready.
Every RTDN push is checked: issuer https://accounts.google.com, audience = push_token_audience, email =
push_service_account_email, email_verified true. Anything else gets 401.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
PROVIDER_PERMISSION_MISSING | Billing account not invited, invited without View financial data, or API not enabled | Redo step 1.4 with all three permissions; permissions can take a while to apply |
PROVIDER_AUTH_REJECTED | Key deleted or account disabled | Create a new key and Rotate |
PUBSUB_SUBSCRIPTION_UNREADABLE | Wrong subscription name, or billing account lacks Pub/Sub Viewer on it | Check the name; add the Viewer grant |
PUBSUB_TOPIC_MISMATCH | Subscription belongs to another topic | Use the subscription on rtdn_topic |
PUBSUB_NOT_PUSH | Delivery type is Pull | Edit the subscription to Push |
PUBSUB_ENDPOINT_MISMATCH | Endpoint is not this connection's Callback URL (other environment or old connection) | Paste the Callback URL from this connection |
PUBSUB_PUSH_UNAUTHENTICATED | Enable authentication not ticked | Tick it and pick the push identity |
PUBSUB_PUSH_IDENTITY_MISMATCH / PUBSUB_AUDIENCE_MISMATCH | Subscription uses another account or audience than the connection fields | Make both sides identical |
PUBSUB_PUBLISHER_MISSING | Play cannot publish to the topic | Grant google-play-developer-notifications@system.gserviceaccount.com Pub/Sub Publisher |
Warning PUBSUB_TOPIC_IAM_UNREADABLE, and Activate returns 409 EVIDENCE_REQUIRED | Billing account lacks Pub/Sub Viewer on the topic, so play-topic is unverified | Add the Viewer grant on the topic and re-run the check |
RTDN pushes get 401 | Token audience or identity differ, or authentication is off | Match push_token_audience and push_service_account_email; check the Token Creator grant |
RTDN pushes get 404 / 503 | Connection ID not active for this environment / connection not active yet | Use the active connection's URL; activate first |
RTDN pushes get 422 | Notification is for another package | One topic and subscription per app and environment |
Purchase returns 404 PRODUCT_NOT_MAPPED | Product ID not mapped in AppCore | Map it in Store mappings and publish |
| Purchase refunded automatically after 3 days | Purchase was never acknowledged (verification never reached AppCore) | Make sure the app sends every purchase to AppCore; the SDK retries unfinished transactions |