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

refactor: webhooks-based approach #16

Merged
merged 12 commits into from
Mar 31, 2023
Merged

refactor: webhooks-based approach #16

merged 12 commits into from
Mar 31, 2023

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Mar 26, 2023

Previously, newly created OAuth users weren't registered as Stripe customers, so their subscriptions couldn't be managed.

This change adds a webhook endpoint for Stripe. When a user's subscription is renewed or cancelled, /api/subscription is called, making a corresponding change to the status of the subscription in the customers table in Supabase.

This PR also includes other minor cleanups, fixes and tweaks.

#19 is a prerequisite for this PR.

@iuioiua iuioiua marked this pull request as ready for review March 30, 2023 04:56
@iuioiua
Copy link
Contributor Author

iuioiua commented Mar 30, 2023

@thorwebdev, is there any chance you'd be able to have a quick look over this? Is this an improvement in design?

.example.env Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Contributor

@thorwebdev thorwebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall, good stuff! \o/

Regarding the usage of Database webhooks to create stripe customer objects. Definitely a valid approach, but alternatively you might want to consider to create the Stripe customer object on the fly the first time it is needed.

@iuioiua
Copy link
Contributor Author

iuioiua commented Mar 30, 2023

Excellent suggestion! I've gone full circle and reverted webhooks for functionality relating to the customers table, and now it's looking much simpler. Thank you.

PTAL, @thorwebdev.

@iuioiua
Copy link
Contributor Author

iuioiua commented Mar 31, 2023

I think there'd be fewer moving parts if stripe_customer_id and is_subscribed were stored in the user's metadata object rather than a customers table. WDYT?

@iuioiua
Copy link
Contributor Author

iuioiua commented Mar 31, 2023

I'll go ahead and merge for now. We can evolve these ideas later.

@iuioiua iuioiua merged commit 9e7dc71 into denoland:main Mar 31, 2023
@iuioiua iuioiua deleted the webhooks branch March 31, 2023 06:31
@thorwebdev
Copy link
Contributor

Sorry for the delay. Yes, LGTM 👍 just added one note above regarding using createOrGetCustomer in the middleware.

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.

2 participants