Hi,
When you refer to `subscription_id` you mean the entitlement id?
You could also be using webhooks for that matter, you would get all the info straight away to the backend without the client needing to pass that information.
You could also be checking at the customerInfo object, inside subscriptions and sort it by date to get the latest one. Would that work for your case?
Best,
Hi Joan,
Thank you for your reply.
I am currently using the v2-beta REST API, where the subscription_id
appears in the format "sub1ab2c3d4e2".
Step 1:
When a user subscribes, I want to send the subscription_id
to the backend, fetch the subscription details via https://api.revenuecat.com/v2/projects/{project_id}/subscriptions/{subscription_id}
, and then grant access to the user. However, the response only includes CustomerInfo
.
Step 2:
Additionally, I want to listen to webhooks on the backend. Here, I also intend to fetch the latest data using the same endpoint: https://api.revenuecat.com/v2/projects/{project_id}/subscriptions/{subscription_id}
. However, it seems that this new subscription_id
(e.g., sub1ab2c3d4e2) is not present in the webhook event payloads.
What I’m doing right now is following:
Current workaround for Step 1:
- After payment I send the
customer_id
from App to the backend. - On Backend: I fetch all subscriptions for the customer via
https://api.revenuecat.com/v2/projects/{project_id}/customers/{customer_id}/subscriptions
. - Sort the subscriptions by date and use the most recent active subscription.
- Fetch the up-to-date subscription data via
https://api.revenuecat.com/v2/projects/{project_id}/subscriptions/{subscription_id}
. - Save the data in our database and return a response to the app.
Current workaround for Webhooks:
- When I receive a webhook event I fetch all customer subscriptions via
https://api.revenuecat.com/v2/projects/{project_id}/customers/{customer_id}/subscriptions
. - Attempt to find the subscription based on the
event.transaction_id
and store_subscription_identifier
(by splitting “..”) - Fetch the up-to-date subscription data via
https://api.revenuecat.com/v2/projects/{project_id}/subscriptions/{subscription_id}
and sync it to the database.
Are there any plans to ensure that the new subscription_id
is present in all relevant places (app SDK and webhook events)?
Thank you,
Jonas