#Anil
1 messages · Page 1 of 1 (latest)
Hello. How can we help?
Hi sir,
- I am creating a checkout.sessions.create for payment.
- After that i am calling a webhook to listen the event's
I am trying to listen three events
checkout.session.completed and invoice.paid and invoice.failed
I am using console there to check but all the three are printing
And i check there are three different event ids
Do you have any idea why is this happening?
They are 3 distinct events, so they will have different event id's. This is expected
Okay so for one payment all the three are printing.
Yeah
What do you mean?
Like if the invoice is paid then only invoice.paid case console should be printed
Well if you are set up to receive all 3 events, then your code will receive all 3 events
That should happen through 3 separate requests to your endpoint though
1 for each event
Okay.
Basically i need webhook because i am using subscription.
So that's why i am using invoice.paid and invoice.paymemt_failed and checkout.session.completed
So what i want to do here is i want to update something in the UI so i have to call an api that i have created in the invoice.paid will that work?
What UI are you trying to update? There's nothing stopping you from calling an api in the webhook handler code
It will update the credits
Like i have a button which will deduct 100$ from account and update the credit in my ui account
Yeah you can do that
Or you can just update your database in the webhook handler code
Yes i will do that
But i am trying to call that api inside invoice.paid but api is not getting called
But when i try to call the api inside checkout.session.completed then api is getting called.
If i have monthly subscription then invoice.paid will be called every month right?
Yes and is there any way i can return something to the ui if invoice paid successfully or fail
Sorry Change your db means
Write the data to your databse
Okay means we directly can't return to ui
Even if have to return simple invoice paid successfully or invoice failed
What ui?
You said you were using checkout sessions
You could also rely on the success_url of the session to pass data
Okay yes we are returning success url and cancel url
But for subscription they will not get called right?
Because payment will be automatically deducted
If they paid successfully on a checkout session for a subscription they'll still be redirected to success url
No this will be gor the first time,
For second month payment will deduct automatically, user will not do anything
Hi 👋 @inner hazel had to step away so I'm taking over