Google Play Console webhooks

Connect Google Play to PurchaseKit so you receive real-time subscription updates (renewals, cancellations, refunds).

Package name

The package name connects your Android app to Google Play Console and PurchaseKit.

Find your package name

  1. Open your Android Studio project
  2. Open app/build.gradle.kts (or build.gradle)
  3. Find the applicationId in the android block: kotlin android { namespace = "com.yourapp.android" defaultConfig { applicationId = "com.yourapp.android" } }

Configure in PurchaseKit

  1. In the PurchaseKit dashboard, go to your app settings
  2. Enter your Google Package Name
  3. Save changes

PurchaseKit uses the package name to match incoming Google webhooks to the correct app.

Run our script in Google Cloud Shell to configure the Pub/Sub topic and service account.

Open Google Cloud Shell

  1. Go to Google Cloud Console
  2. Select your project from the dropdown at the top
  3. Click the Cloud Shell icon (terminal icon) in the top-right toolbar
  4. Wait for the shell to initialize

Create and run the script

  1. In Cloud Shell, click Open Editor (pencil icon) to open the editor
  2. Click File → New File
  3. Copy the script from purchasekit.com/scripts/google-setup.sh and paste it
  4. Change line 18: replace your_project_id with your Google Cloud project ID
  5. Click File → Save As and name it setup.sh
  6. Click Open Terminal to return to the terminal
  7. Run the script: bash setup.sh

Google Cloud Shell Editor
Google Cloud Shell Editor

After the script completes:

  1. Add the service account to Play Console
  2. Enable real-time notifications in your app
  3. Upload the JSON key to PurchaseKit

Manual setup

If you prefer to configure everything manually, follow the steps below.

Google Cloud project

  1. Go to Google Cloud Console
  2. Click the project dropdown at the top
  3. Click New Project
  4. Enter a name (e.g., "My App Purchases")
  5. Click Create

Enable APIs

  1. In Google Cloud Console, go to APIs & ServicesLibrary
  2. Search for and enable:
    • Cloud Pub/Sub API
    • Google Play Developer API

Create a Pub/Sub topic

  1. Go to Pub/SubTopics
  2. Click Create Topic
  3. Enter a topic ID (e.g., purchasekit-play-notifications)
  4. Uncheck "Add a default subscription"
  5. Click Create

Create a push subscription

  1. Click on your newly created topic
  2. Click Create Subscription
  3. Enter a subscription ID (e.g., purchasekit-push)
  4. Set Delivery type to Push
  5. Enter the PurchaseKit webhook URL: https://purchasekit.com/webhooks/google
  6. Click Create

Grant Pub/Sub permissions

Google Play needs permission to publish to your topic:

  1. Go to Pub/SubTopics
  2. Click on your topic
  3. Click the Permissions tab
  4. Click Grant Access
  5. For New principals, enter: google-play-developer-notifications@system.gserviceaccount.com
  6. For Role, select Pub/Sub Publisher
  7. Click Save

Create a service account

PurchaseKit needs a service account to fetch subscription details from Google Play.

  1. In Google Cloud Console, go to IAM & AdminService Accounts
  2. Click Create Service Account
  3. Enter a name (e.g., "PurchaseKit")
  4. Click Create and Continue
  5. Skip the optional steps and click Done

Generate a key

  1. Click on your new service account
  2. Go to the Keys tab
  3. Click Add KeyCreate new key
  4. Select JSON
  5. Click Create
  6. Save the downloaded file securely
  1. Open Google Play Console
  2. Go to Users and permissions (in the left sidebar, under Setup)
  3. Click Invite new users
  4. Enter the service account email (looks like name@project.iam.gserviceaccount.com)
  5. Set permissions:
    • Account permissions: View app information and download bulk reports
    • Financial data: View financial data, orders, and cancellation survey responses
  6. Click Invite user
  7. Click Apply on the access level page

Note: Permissions can take up to 24 hours to propagate.

Upload to PurchaseKit

  1. In the PurchaseKit dashboard, go to AccountDeveloper
  2. Upload the JSON key file you downloaded
  3. Click Upload credentials

Enable real-time notifications

  1. In Google Play Console, select your app
  2. Go to MonetizeMonetization setup
  3. Scroll to Real-time developer notifications
  4. Enter your Cloud Pub/Sub topic name: projects/YOUR_PROJECT_ID/topics/purchasekit-play-notifications (Replace YOUR_PROJECT_ID with your Google Cloud project ID)
  5. Click Save changes

Test the connection

  1. Click Send test notification
  2. Check the PurchaseKit dashboard for the incoming webhook
  3. If no webhook appears, verify:
    • Pub/Sub subscription URL is correct
    • Pub/Sub Publisher permission is granted
    • Service account permissions have propagated (wait 24 hours)

Next step

Return to Getting started to complete your PurchaseKit integration, or see Android setup if you haven't added the PurchaseKit library yet.