RevenueCat webhook to sync subscriptions #547
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
This PR exposes a new endpoint,
/webhooks/revenue_cat, for RevenueCat to POST webhooks to. The user ID is extracted from the payload and a generic "sync" workflow is kicked off. Each webhook is handled the same way, regardless of the type of event that is sent, from RevenueCat's recommendation.The syncing workflow uses Tarpon to interact with RevenueCat's REST API. The user's subscription status is requested and then written to a fake payment processor via the Pay gem. This aligns with Stripe subscriptions so existing infrastructure can be used to verify permissions for paying customers.
In the future, a full-blown RevenueCat payment processor could be implemented. But for now, I think this should get us what we need!
Pull request checklist
bin/checkI added significant changes and product updates to the changelog