Skip to content

Android Google Play Pub/Sub Setup ​

how to configure Google Play Real-Time Developer Notifications (RTDN) for Android subscriptions using Google Cloud Pub/Sub

1. Google Cloud Project ​

Open the required project in Google Cloud Console.

Example project

text
Project name: GoBiz Demo
Project ID:   gobiz-demo

All Pub/Sub resources used for this integration should be created inside the Google Cloud project configured for the Android application.

2. Create a Google Cloud Service Account ​

Open:

Google Cloud Console → IAM & Admin → Service Accounts

Click Create service account.

Service account configuration

FieldExample
Service account nameplay-api
Service account IDplay-api
DescriptionTo receive Google Play subscription messages.
RolePub/Sub Admin

The resulting service-account email will look similar to:

Click Create and continue and complete the service-account creation.

3. Create the Service Account JSON Key ​

After creating the service account:

  1. Open Google Cloud Console → IAM & Admin → Service Accounts.
  2. Locate the play-api service account.
  3. Open the Actions menu.
  4. Select Manage keys.
  5. Click Add key.
  6. Select Create new key.
  7. Select JSON.
  8. Click Create.

Google Cloud will download the JSON credentials file to your computer.

Rename the downloaded file to:

text
service-accounts.json

This file is required by the server-side application to authenticate with Google APIs.

4. Create the Pub/Sub Topic ​

Open:

Google Cloud Console → Pub/Sub → Topics

Click Create topic.

Topic configuration

Set the Topic ID to:

text
play-notifications

Enable:

text
Add a default subscription

After creation, the topic resource will look similar to:

text
projects/gobiz-demo/topics/play-notifications

Verify that the topic appears under:

Pub/Sub → Topics

Configure the topic in Google Play Console

Copy the complete topic name:

text
projects/gobiz-demo/topics/play-notifications

Then open:

Google Play Console → Monetize with Play → Monetization setup

Paste the complete topic name into the Topic name field.

Save the configuration.

Important: Use the complete Pub/Sub resource name, not only play-notifications.

5. Grant Pub/Sub Publisher Permission ​

Google Play needs permission to publish RTDN messages to the Pub/Sub topic.

Open:

Google Cloud Console → Pub/Sub → Topics

Select:

text
play-notifications

Open the topic's Permissions / Access configuration and select Grant access.

Principal

Add:

Role

Assign:

text
Pub/Sub Publisher

Save the permission.

Verify the permission

Open the topic's permissions panel and confirm that the following entry exists:

text
Role:
Pub/Sub Publisher

Principal:
[email protected]

Google Cloud may indicate that the permission change can take a few minutes to become active.

Important: Do not use the play-api service account as the publisher principal. Google Play publishes RTDN messages using [email protected].

6. Configure Google Play Console Permissions ​

Open:

Google Play Console → Users and permissions

Click Invite new users.

Enter the Google Cloud service-account email created in Step 2.

Example

Important: Use the play-api service account here.

6.1 Grant App Permission

Under App permissions:

  1. Select your application.
  2. Click Apply.
  3. Grant:
text
- View app information (read-only)
- View financial data
- Manage orders and subscriptions

Do not grant Admin (all permissions) unless the application integration specifically requires it.

These permissions allow the server-side integration to access the Google Play purchase and subscription information required for subscription management.

Click Apply / Invite user to save the permissions.

Verify the service-account permissions

The play-api service account should have:

text
App permission:
View app information (read-only)

Financial permissions:
View financial data
Manage orders and subscriptions

7. Configure Google Play Real-Time Developer Notifications ​

Open the Android application in Google Play Console.

Navigate to:

Monetize with Play → Monetization setup

Find:

Google Play Billing

Locate:

Real-time developer notifications

Enable:

text
Enable real-time notifications

7.1 Enter the Pub/Sub Topic

In Topic name, enter the complete Pub/Sub topic resource:

text
projects/gobiz-demo/topics/play-notifications

The complete resource name is required.

Google Play will publish subscription and purchase notification messages to this Pub/Sub topic.

7.2 Select Notification Content

Select:

text
Subscriptions and voided purchases only

Save the Google Play Billing configuration.

Verify the RTDN configuration

Before continuing, confirm:

text
RTDN:
Enabled

Topic:
projects/gobiz-demo/topics/play-notifications

Notification content:
Subscriptions and voided purchases only

8. Create the Pub/Sub Subscription ​

Open:

Google Cloud Console → Pub/Sub → Subscriptions

If Add a default subscription was enabled while creating the topic, a subscription may already have been created automatically.

The expected subscription name in this setup is:

text
play-notifications-sub

If it does not already exist, create a subscription for the topic.

Subscription configuration

text
Subscription ID:
play-notifications-sub

The resulting subscription resource will look similar to:

text
projects/gobiz-demo/subscriptions/play-notifications-sub

The subscription must be attached to:

text
projects/gobiz-demo/topics/play-notifications

Verify the subscription

Confirm that:

text
Subscription:
play-notifications-sub

Topic:
play-notifications

The subscription is responsible for receiving messages published by Google Play to the Pub/Sub topic.

9. Configure the Subscription Delivery Type ​

Open:

Google Cloud Console → Pub/Sub → Subscriptions → play-notifications-sub

Click Edit.

Change the delivery type to:

text
Push

The push subscription sends Pub/Sub messages directly to the application's webhook endpoint.

9.1 Get the Android Webhook URL

Open the GoBiz Admin Panel.

Navigate to:

Plugins → Mobile App API

Locate:

Webhook URL (Android)

Copy the Android webhook URL.

9.2 Configure the Push Endpoint

Return to:

Google Cloud Console → Pub/Sub → Subscriptions → play-notifications-sub → Edit

Under Push configuration, set:

text
Delivery type:
Push

Endpoint URL:
<Android Webhook URL copied from GoBiz Admin Panel>

9.3 Enable Authentication

select Enable.

For Service account, select the service account created in Step 2:

For Audience (Optional), enter the same webhook endpoint URL.

Push configuration should look similar to:

text
Delivery type:
Push

Endpoint URL:
<Android Webhook URL>

Authentication:
Enabled

Service account:
[email protected]

Audience:
<Android Webhook URL>

Save the subscription configuration.

9.4 Test the Google Play Notification

After saving the Pub/Sub push configuration:

  1. Open Google Play Console.
  2. Navigate to Monetize with Play → Monetization setup.
  3. Open the Google Play Billing configuration.
  4. Locate the configured Topic name.
  5. Click Send test notification.

Google Play will send a test RTDN message to the configured Pub/Sub topic.

The Pub/Sub subscription should then deliver the message to the configured Android webhook endpoint.

If the test notification reaches the application successfully, the Pub/Sub RTDN connection is configured correctly.

10. Server Configuration — Upload service-accounts.json ​

The Google Cloud service-account JSON file created in Step 3 must be uploaded to the application server.

Open the server's File Manager.

Navigate to:

text
storage
└── app
    └── google

If the google directory already exists, open it.

Upload:

text
service-accounts.json

The final file path must be:

text
storage/app/google/service-accounts.json

Video Tutorial ​

https://vimeo.com/1221050963?fl=tl&fe=ec

https://vimeo.com/1221050961?fl=tl&fe=ec

© 2021-present GoBiz SaaS. All rights reserved.