Evelin Ponce
Evelin Ponce

Reputation: 1126

How to determine if a subscription notification come from a test account in Android

When a subscription notification from an inapp product (using real-time PUB/SUB) reach our server, how can we know if that notification came from a test purchase? In the Google documentation said that the PUB/SUB test notifications have an attribute as testNotification but this attribute only shows when the notification was created in the Cloud Platform, but this attribute doesn't appear when the notification was a subscription notification.

Upvotes: 5

Views: 1238

Answers (1)

Sébastien Dubois
Sébastien Dubois

Reputation: 999

Once you have the Pub/Sub notification:

  • Base64-decode the payload's message.data, parse the JSON, and extract packageName, subscriptionNotification.subscriptionId and subscriptionNotification.purchaseToken. See documentation.
  • send a get request with those 3 items to the Android Publisher Subscription Purchase API. See documentation.
  • If it is a test subscription, the response will contain purchaseType: 0.

Upvotes: 1

Related Questions