Stripe SUBSCRIPTIONS with Next.js & Supabase

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 18

  • @constantintonagel2357
    @constantintonagel2357 Місяць тому +1

    Important: The env variables should not be used in a client component to not leak them, that's the reason you cant get the secret key from the env file (Its used in the SubscribeButton Component which is Client Side). Directly declaring them there will just leak really secret data to the client.
    Solution: Server Actions, for example like:
    export default function TestSubscribeButton({userId}: {userId: string}) {
    async function handleSubscribe() {
    'use server'

    const url = await handleStripeSubscription(userId)
    if (url) {
    redirect(url)
    } else {
    throw new Error('Failed to create subscription session')
    }
    }
    return (...
    Otherwise really awesome stuff, helped a lot to get a quick start, much thanks man!!!

  • @Alex030kov
    @Alex030kov 4 місяці тому +2

    Cole coming in clutch 🥂 Keep up the good content

    • @coleblender
      @coleblender  4 місяці тому +1

      Appreciate it cuz 🙏🏼 I definitely got a lot more coming so stay tuned 🎥

  • @joshDotJS
    @joshDotJS 4 місяці тому +1

    bruh..... you are killing it! please keep it up!!!!!

    • @coleblender
      @coleblender  4 місяці тому

      You’re an absolute hype God thank you bro!! Definitely got way more in the bag!!

  • @gabrielgarayalde1693
    @gabrielgarayalde1693 2 місяці тому

    Bro I just discovered you today, and you are an absolute fucking G - keep making these videos, theyre so good

    • @coleblender
      @coleblender  2 місяці тому +1

      Fuck yeah bro I appreciate it!! I’ve been busy with a new job so I haven’t dropped in a while but I’ll be back very soon 🫡

  • @Alex030kov
    @Alex030kov 4 місяці тому +2

    Does the database automatically update is_subscribed when the user has stopped the subscription ?

    • @coleblender
      @coleblender  4 місяці тому

      Very good question. No it does not. In the api/stripe/route.ts file you add a part to the if else statement that handles that. It would be event.type === “customer.subscription.deleted”. So you would manually do it if the event type is that

    • @coleblender
      @coleblender  4 місяці тому

      I also believe that you have to configure the webhook in the Stripe dashboard to trigger when this event happens. So you have to setup Stripe send the request to your API endpoint when this happens (your app/api/stripe/route.ts file) and then make it so that this file does what you want when it receives the request from Stripe. There are many different events that you can set up.

    • @Alex030kov
      @Alex030kov 4 місяці тому

      @@coleblenderunderstood, thank you very much!

  • @QtheCoder
    @QtheCoder Місяць тому

    for Supabase what RLS do you have to setup to allow webhook to update or insert data?

    • @coleblender
      @coleblender  Місяць тому

      MASTER Supabase Security - Auth and RLS for Secure Storage
      ua-cam.com/video/MA09FD_yGKo/v-deo.html
      In this video I talk about RLS. Maybe it could help

  • @VincentFulco
    @VincentFulco 4 місяці тому

    Great example, stripe wasn't working since the signing key "key" was misspelled in the .env. Otherwise, awesome. Thanks again!

    • @coleblender
      @coleblender  4 місяці тому +1

      Hell yeah man thanks! And yeah idk what was going on. When I run a console.log() in the stripe config file it successfully logs out the .env variable

  • @madisopabul
    @madisopabul 10 годин тому

    very poor

    • @coleblender
      @coleblender  10 годин тому

      What part of this video wasn’t up to your standard?