How to PubSub subscribe only to Google Play test purchase notifications?

Viewed 64

The Google Play console allows only one PubSub topic per Google Play app. So all Real Time Developer Notifications from the app, the production and test purchases, end up in the same PubSub topic queue.

How can I create a PubSub subscription to a topic that retrieves only the Real Time Developer Notifications for a specific environment (test purchases / production purchases)?

The only related indication in the docs is to separate the PubSub topic per app, but it doesn't say anything about test vs. production purchases:

Note: You must configure Real-time developer notifications for each Android app separately. This means that you can choose to use the same GCP project as the one used to access the Play Developer API, or you can create a new GCP project for each app. If you have multiple apps, you must use the same Google Cloud Console project for the Google Play Developer API, but you can use different Google Cloud Console projects for each individual app.

A PubSub subscription has a filter option but I’m unsure whether that can be used for that purpose. Taking a look at a PubSub message, this is the only info we have:

{
  "version": "1.0",
  "packageName": "com.example.app",
  "eventTimeMillis": "1660476234972",
  "subscriptionNotification": {
    "version": "1.0",
    "notificationType": 4,
    "purchaseToken": "abc",
    "subscriptionId": "com.example.app.premium.development"
  }
}

So one way could be to filter by subscriptionId if the development version of the app uses a specific set of subscriptions reserved for development. But it seems that the filter option does not work for values in the message body but only for the message attributes.

0 Answers
Related