Skip to main content
Solved

Finding purchase_token from Android purchases

  • September 9, 2021
  • 5 replies
  • 956 views

Forum|alt.badge.img

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..?

Best answer by tina

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?

View original
Did this post help you find an answer to your question?

5 replies

tina
RevenueCat Staff
Forum|alt.badge.img+10
  • RevenueCat Staff
  • 338 replies
  • Answer
  • September 14, 2021

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?


Forum|alt.badge.img
  • Author
  • New Member
  • 3 replies
  • September 15, 2021

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? 


tina
RevenueCat Staff
Forum|alt.badge.img+10
  • RevenueCat Staff
  • 338 replies
  • September 15, 2021

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. 


Forum|alt.badge.img+3
tina wrote:

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. 


Forum|alt.badge.img+3
  • New Member
  • 1 reply
  • October 3, 2023
kishan-e80b39 wrote:


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.)


Did this post help you find an answer to your question?

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings