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

Issue with keeping website products in sync with Stripe products? #377

Open
KamilTheDev opened this issue Oct 2, 2024 · 1 comment
Open

Comments

@KamilTheDev
Copy link

Is there a way to properly resync the website with the latest Stripe products?

For example, if starting out using a localhost version, and then later deploying a website version - the products will be empty. I believe this is since only localhost version was running first, and products were created, so only localhost database got the webhook events. This means in website version, the products are empty since it never received the webhooks when products were created.

In a video tutorial, their solution is to archive existing Stripe products and recreate them again. I feel this is inefficient.

I was also wondering, lets say that the website went down, and you created or modified Stripe products. When the website is back up, won't the website be out of sync with Stripe since the webhook wasn't online?

Could there be a solution such as fetching all the Stripe products at build time, and also having a method to manually occur a resync with Stripe products if anything becomes out of sync?

Unless this is already possible and I'm missing it, please let me know.

@k-thornton
Copy link
Contributor

While in development I've personally just been modifying the product/price description to trigger a re-sync with my local DB. Really, the bigger concern is that if you're missing product upgrade webhook events, you're certainly going to be missing subscriptions, payments, and all that kind of business stuff.

I think if you're not confident your site will be running all the time, the 2 solutions I got working were:

  1. Use a Supabase Edge Function to host a very lightweight webhook processing script. They even made a little tutorial for this https://supabase.com/docs/guides/functions/examples/stripe-webhooks
    It worked well but ultimately there was more business logic I wanted to run in my webhook handler, and didn't like it silo'ed off in its own separate service. If all you want is to keep the database up to date, this is a great way to do it.
  2. Ditch the stripe stuff out of your database, and the webhooks... use a data wrapper instead. This will let you query live data directly from Stripe as needed.
    https://supabase.com/partners/integrations/supabase_wrapper_stripe
    In my experience this worked really seamlessly, though came at a noticeable cost to performance. It might have been improved since I tried it.

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

No branches or pull requests

2 participants