I am upgrading AndroidPublisher library from v1 to v3 for my secure backend server. AndroidPublisher library (v3) will allows me to do server side purchase validation and acknowledgement for in-app purchases and subscription securely.
Existing code for v1 is not compatible anymore. The v3 library looks better but I could not find any sample code for:
- Build client credential using client JSON.
Get
&Acknowledge
Purchases using PurchaseToken.
Maven setting:
<project>
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-androidpublisher</artifactId>
<version>v3-rev103-1.25.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.30.2</version>
</dependency>
</dependencies>
</project>
API documentation: https://developers.google.com/android-publisher/api-ref/purchases/products/get
Looking for a sample like this: https://developers.google.com/api-client-library/java/google-api-java-client/samples
Any short sample code would be a great help.
Add following dependencies
Then enable Google Developer Play Api library from Google Cloud Console here
In credentials Create service account key with role
Pub/Sub Admin
and save json fileIn Google developers Console here. In
Settings >> Developer Account >> API Access
link your app.Then in code do following to get subscription info.
Note: if you get this error:
Then try again after one day because after enable google play developer api and creating service account key from google console you need to wait 24 to 48 hours and also do following
From Google Play Console go to (with admin access):