0

For in-app subscription I'm using this code (in Kotlin)

iabHelper.launchSubscriptionPurchaseFlow(act, "month", 1001, this@SubscriptionActivity, extraKey)

After this I'm making request to server for purchase verifying. For verification on server I'm using this code (in Go)

result, err := androidpublisher.Purchases.Subscriptions.Get(packageName, product, token).Do()
success := err == nil

How to get extraKey which I passed in app? I need it to know, which user made purchase

Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86

1 Answers1

0

I was confused by parameter name "extraData", and was looking for same field in request result. But when I looked at the IabHelper source, I found this

@param extraData Extra data (developer payload), which will be returned with the purchase * data when the purchase completes. This extra data will be permanently bound to that * purchase and will always be returned when the purchase is queried

So, extra data is in DeveloperPayload field

result, err := publ.Purchases.Subscriptions.Get(packageName, product, token).Do()
success := err == nil && result.DeveloperPayload == extraKey

Also, note, which can be useful for those, who aren't reading docs

Note: Do not use the user's email address in the payload string, since that address may change.

Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86