androidgoogle-playin-app-purchaseandroid-inapp-purchase

In App Purchases where I can get the token?


On official page https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get

the following HTTP request suppose to be send https://www.googleapis.com/androidpublisher/v3/applications/packageName/purchases/subscriptions/subscriptionId/tokens/token

As last parameter we need to send token. It says The token provided to the user's device when the subscription was purchased.

But how I can get it since there is no returned object after the subscription was done? Or I missed anything?


Solution

  • You can get it from purchase object purchase.getPurchaseToken() inside of onPurchasesUpdated() method. tokens are generated when purchase is successful.

    related doc: https://developer.android.com/google/play/billing/integrate#launch