I want to fetch state from API in addition to webhook handling, for improved resilience.
My subscriptions are credits based, when there’s initial/renewal event, I assign a number of credits to the user.
Not sure how to proceed with the transfer webhook event:
The user installs the app on device A: they get id 1. The user subscribes. My backend has id 1 → 10 credits.
The user installs the app on device B: they get id 2.
Let’s say that the backend for some reason doesn’t receive or process the transfer webhook, so it’s not aware that id 1 → id 2
Now device B, with its id 2, triggers a refresh from RevenueCat api: I get that id 2 has a subscription.
Since I don’t have the old id, all I can do here is to create a new record for id 2 with 10 credits, as if it was a new user. Which is incorrect, because it’s effectively duplicating the credits for the user, who can now use 10 credits on device A and 10 credits on device B.
How can I associate the subscription data to the old id?
Also, is the whole reasoning correct, or am I missing something else?
Thanks!
Noting that my webhook transfer handler basically removes the old user and creates a new one with the same data and new id (thereby a “transfer”). Not 100% sure that this behavior is correct / expected, but at least it’s straight forward technically.
Using subscriptions endpoint:
"https://api.revenuecat.com/v2/projects/$projectId/customers/$userIdStr/subscriptions"
