I have a mobile app (iOS/Android) and the backend is built with Django+MySQL. My app offers a monthly/yearly “premium user” subscription and we’re using RevenueCat to handle IAPs. But we also want to keep the subscription status (isPremiumUser or not) of a user in our own database’s user records as well.
Webhooks are commonly used to keep a subscribers status in sync with RevenueCat across multiple systems. To simplify the logic of handling different webhook types, we recommend creating a polling system using the GET /subscribers REST API to sync the subscription status of the customer from RevenueCat to your database. Then, each webhook event can simply be a trigger to call this sync function. This approach has a few benefits and can make your system more robust and scalable.
The way I understand is, below are the steps to implement such a system.
1. Register URL to receive webhook events.
1.1. Send 200 response back to RevenueCat servers when a webhook event is received.
2. Every time a webhook is received, get the 'original_app_user_id' from the response.
3. Call /subscribers/<original_app_user_id> to get the subscriber info.
4. Determine whether the user currently has an active subscription.
5. Update my database's user object 'isPremiumUser' property accordingly.
Now my question has a few parts.
- Is my approach correct? Am I missing any steps?
- How do I actually determine whether the user is subscribed or not? What fields in the JSON should I check?
- In the REST API’s docs, it says if I call the /subscribers endpoint with a user id and that user doesn’t exist, it will create one. Wouldn’t that be a problem?
I’d really appreciate any help to get these clarified. Thanks in advance.