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!!!
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
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.
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!!!
Cole coming in clutch 🥂 Keep up the good content
Appreciate it cuz 🙏🏼 I definitely got a lot more coming so stay tuned 🎥
bruh..... you are killing it! please keep it up!!!!!
You’re an absolute hype God thank you bro!! Definitely got way more in the bag!!
Bro I just discovered you today, and you are an absolute fucking G - keep making these videos, theyre so good
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 🫡
Does the database automatically update is_subscribed when the user has stopped the subscription ?
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
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.
@@coleblenderunderstood, thank you very much!
for Supabase what RLS do you have to setup to allow webhook to update or insert data?
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
Great example, stripe wasn't working since the signing key "key" was misspelled in the .env. Otherwise, awesome. Thanks again!
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
very poor
What part of this video wasn’t up to your standard?