Skip to main content
Answer

How to Verify One-Time Purchases Using RevenueCat REST API (v2)?

  • December 9, 2024
  • 1 reply
  • 545 views

Forum|alt.badge.img

Hi, I’m implementing one-time purchases using RevenueCat.

I’ve set up a webhook to receive data when a user successfully completes a purchase. However, for security reasons, I don’t fully trust the data received via the webhook and want to verify the purchase using RevenueCat's REST API (v2).

I’ve gone through the documentation but couldn’t find a clear endpoint to validate one-time purchases. Could you help me with the following questions?

  1. Which endpoint should I use to validate a one-time purchase?
  2. What parameters should I include in the request? For example, should I use id, transaction_id, or app_user_id from the webhook data?
  3. Can the /v2/projects/{project_id}/purchases/{purchase_id} endpoint be used for this purpose? If so, what value should be passed as {purchase_id}?

Best answer by Haley Pace

Hi,

  1. Once a purchase is made RevenueCat will validate the purchases with Apple/Google with the fetch token received. If you wanted to make sure it went through you can listen to the purchase webhook or you could use the purchase completed callback shown here to make sure it went through/was validated
  2. If you are referring to our ‘Get a purchase’ APIv2 endpoint here then you will need to use the project_id and purchase_id and you can get the former from our ‘Get a list of projects’ APIv2 endpoint here

  3. You get the purchase_id from our ‘Get a list of purchases associated with a customer’ APIv2 endpoint here
This post has been closed for comments

1 reply

Forum|alt.badge.img+8
  • RevenueCat Staff
  • Answer
  • December 11, 2024

Hi,

  1. Once a purchase is made RevenueCat will validate the purchases with Apple/Google with the fetch token received. If you wanted to make sure it went through you can listen to the purchase webhook or you could use the purchase completed callback shown here to make sure it went through/was validated
  2. If you are referring to our ‘Get a purchase’ APIv2 endpoint here then you will need to use the project_id and purchase_id and you can get the former from our ‘Get a list of projects’ APIv2 endpoint here

  3. You get the purchase_id from our ‘Get a list of purchases associated with a customer’ APIv2 endpoint here