Next.js Discord

Discord Forum

stripe integration

Unanswered
Mossyrose gall wasp posted this in #help-forum
Open in Discord
Mossyrose gall waspOP
I have integrated stripe in my next app. I have included three subscription plans. I created the checkout link for three plans, but I don't get how can I know which plan did the user has subscribed. I am sharing my code with you all. Please help

49 Replies

Mossyrose gall waspOP
Mossyrose gall waspOP
From where I can givee the webhook url to the stripe, through stripe dashboard or have to configure it in the code?
@Mossyrose gall wasp From where I can givee the webhook url to the stripe, through stripe dashboard or have to configure it in the code?
you add the webhook at stripes dashboard. There you specify an url that will be called, whenever the choosen event happens and this url is normally an url to your server, so you are able to handle that event
I guess you want to use the event checkout.session.complete. I guess it's called like that
Mossyrose gall waspOP
at 5 pm GMT.
@Mossyrose gall wasp tried?
Mossyrose gall waspOP
I tried, so many webhooks are fired by stripe and i dont know which one I have to use for simple 3 monthly base subscription plans
@Mossyrose gall wasp I tried, so many webhooks are fired by stripe and i dont know which one I have to use for simple 3 monthly base subscription plans
You can use this: https://nextjs-forum.com/post/1249422954820014171#message-1249648980200259636
Or if you just want to check the creation of the subsription (you also get the needed id) you can use the customer.subscription.created event (I guess it's called like that)
Mossyrose gall waspOP
I also want to know if a user cancels the subscription
@Mossyrose gall wasp I also want to know if a user cancels the subscription
then you can check the customer.subscription.updated and customer.subscription.deleted events. If one of the events is called, revoke the access
Mossyrose gall waspOP
What happens if the user again subscribes?
@Mossyrose gall wasp What happens if the user again subscribes?
then the customer.subscription.updated event will be triggered. Check, if the subscription is active or not and if not active, revoke the access
Mossyrose gall waspOP
Ok will definitely try that
@B33fb0n3 where are you from?
@B33fb0n3 from germany, you?
Mossyrose gall waspOP
Pakistan
Are you doing any job there?
yea
Mossyrose gall waspOP
As a?
I keep most of my details private, sorry
@B33fb0n3 I keep most of my details private, sorry
Mossyrose gall waspOP
Cool
@Mossyrose gall wasp Ok will definitely try that
when will you try?
@B33fb0n3 when will you try?
Mossyrose gall waspOP
Tomorrow
@Mossyrose gall wasp tried?
@B33fb0n3 <@934025913304240202> tried?
Mossyrose gall waspOP
I have tried it and the webhook is working, but things are not clear bcz the data given by stripe is not very clear
Mossyrose gall waspOP
I don't know but feels something missing. Sending you the webhook api give suggestions what is missing or made better
Mossyrose gall waspOP
@Mossyrose gall wasp Click to see attachment
I am a little bit confused...
Mossyrose gall waspOP
why?
@Mossyrose gall wasp I have tried it and the webhook is working, but things are not clear bcz the data given by stripe is not very clear
Madeiran sardinella
You can see in the stripe dashboard the shape and the response of every webhook sent to your app.
Mossyrose gall waspOP
No I mean they give webhook on every call or on every event and I don't get which webhook to listen to or which webhooks are important.
@Madeiran sardinella I use charge.succeeded
I heared about charge.succeeded, that it sometimes will be called multiple times... I won't use it
@B33fb0n3 I heared about charge.succeeded, that it sometimes will be called multiple times... I won't use it
Madeiran sardinella
Where did you hear that bro? Is there an opened issue or link that you can share?
It works pretty well for me
Mossyrose gall waspOP
can you please list down all important webhooks to listen to.
I am already listening to these two
customer.subscription.updated
checkout.session.complete
is this enough.
and what does charge.succeeded do?
@Madeiran sardinella Where did you hear that bro? Is there an opened issue or link that you can share? It works pretty well for me
I heared it in an issue here in help-forum. You might find it when searching in help-forum with my name and something about stripe or directly the carge succceeded event
Mossyrose gall waspOP
I want to implement stripe completely in my app with the required webhooks. if you have any example code of git repo, it might help me. or make changes in the code that I share.
@Mossyrose gall wasp I want to implement stripe completely in my app with the required webhooks. if you have any example code of git repo, it might help me. or make changes in the code that I share.
I would just follow their guide: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=stripe-hosted#provision-and-monitor
It seems like these are the minimum event types to monitor. These are different from your choosen ones
But for subscriptions there is a whole guide just about webhooks for subscriptions: https://docs.stripe.com/billing/subscriptions/webhooks
@Mossyrose gall wasp tried?
Mossyrose gall waspOP
I was taking some days for rest, will look into it when have time