Solved

Finding purchase_token from Android purchases

  • 9 September 2021
  • 5 replies
  • 613 views

Badge

We wish to integrate our sales data with ChartMogul. We need to send payloads to ChartMogul with data about every purchase. 

 

In section 3 of this link from ChartMogul, it is described: 

  • purchase_token - Mandatory - The purchaseToken returned by Google Play as soon as a purchase is completed. This is usually returned within the INAPP_PURCHASE_DATA object in the getBuyIntent() method.

 

How can we access this purchase_token? We are using the webhooks sent from RevenueCat to our backend, to align our userbase with the purchasing events from RevenueCat. However there is no purchase_token field on any of these events. I assume it has been renamed..?

icon

Best answer by tina 14 September 2021, 22:39

View original

5 replies

Badge +2

Hey @Johan!

The purchase token isn’t exposed through RevenueCat’s APIs/webhooks. RevenueCat tries to abstract in-app purchases as much as possible and exposing the receipt/purchase_token is a different process between Android and iOS. If you’re utilizing the native Android Purchases SDK, you should be able to get the original token in the purchase completion block in the SDK and save it from there. 

There are some technical limitations that keep us from returning the raw receipt data in the GET /subscribers API response, so the best way to access this information would be directly from the device. The purchase token is available through native Android methods so you shouldn't need any third party libraries to access this.

Does this sound like it would work for you?

As per fraud prevention Android Developer Official docs stated to maintain the purchase token to reverify on our backend. https://developer.android.com/google/play/billing/security#verify

I am requesting a way to have purchase_token for android and the_base64_encoded_receipt_data for iOS to support web based backends. 

Badge +2


I am requesting a way to have purchase_token for android and the_base64_encoded_receipt_data for iOS to support web based backends. 

 

If we want to leave RevenueCat at some point, can we get the purchase token and receipt data?

(Nothing personal but we’re evaluating moving to RevenueCat from direct SDK support on Android/IOS and management will be asking if we’ll be locked in.)

Userlevel 5
Badge +10

Hey @Johan!

The purchase token isn’t exposed through RevenueCat’s APIs/webhooks. RevenueCat tries to abstract in-app purchases as much as possible and exposing the receipt/purchase_token is a different process between Android and iOS. If you’re utilizing the native Android Purchases SDK, you should be able to get the original token in the purchase completion block in the SDK and save it from there. 

There are some technical limitations that keep us from returning the raw receipt data in the GET /subscribers API response, so the best way to access this information would be directly from the device. The purchase token is available through native Android methods so you shouldn't need any third party libraries to access this.

Does this sound like it would work for you?

Badge

Hey @tina,

Thanks for getting back to me. 
We are working with React-Native and would prefer to avoid meddling with native code, at least if it’s possible. Ideally we would be able to access the purchase token for Android purchases through the webhooks sent to our backend. 

Is there any other way for us to access the token besides implementing native Java/Kotlin code? 

Userlevel 5
Badge +10

Unfortunately RevenueCat does not send over the purchase_token through webhooks or API :/ The purchase token would need to accessed directly from the device through native Android code. 

Reply