Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RevenueCat webhook to sync subscriptions #547

Merged
merged 1 commit into from Jul 9, 2022
Merged

Conversation

joemasilotti
Copy link
Owner

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

  • My code contains tests covering the code I modified
  • I linted and tested the project with bin/check
  • I added significant changes and product updates to the changelog

@@ -0,0 +1,24 @@
module Webhooks
class RevenueCatController < ApplicationController
skip_before_action :verify_authenticity_token, only: :create

Check failure

Code scanning / CodeQL

CSRF protection weakened or disabled High

Potential CSRF vulnerability due to forgery protection being disabled or weakened.
@joemasilotti joemasilotti force-pushed the revenue-cat-webhooks branch 2 times, most recently from e48cdbd to b7e645c Compare July 9, 2022 12:39
@joemasilotti joemasilotti mentioned this pull request Jul 9, 2022
3 tasks
@joemasilotti joemasilotti merged commit acee078 into main Jul 9, 2022
5 checks passed
@joemasilotti joemasilotti deleted the revenue-cat-webhooks branch July 9, 2022 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant