Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 588
Evelin Ponce Avatar asked Nov 18 '22 22:11

Evelin Ponce


1 Answers

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.
like image 114
Sébastien Dubois Avatar answered Dec 20 '22 17:12

Sébastien Dubois