#nit_sin
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
it was working previously but now no its giving no response
do you mean this https://stripe.com/docs/api/webhook_endpoints ?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
/webhook_endpints?
do you have an event ID?
nope
since i am not getting any response
I am running this in my cmd
stripe listen --forward-to localhost:3001/webhook
and adding endpoint to receive the events in developer->webhooks
you don't have to add an endpoint if you are using Stripe CLI to forward your events to your localhost
would you mind sharing your code please?
yeah I am not using stripe cli
I am using ngrok to create a public url and forward that to localhost
stripe listen --forward-to localhost:3001/webhook
this is Stripe CLI
this is not related and you can disregard that
would you mind sharing your code please?
Yeah
`app.post(
'/webhook',
express.raw({ type: 'application/json' }),
async (request, response) => {
const sig = request.headers['stripe-signature']
let event
try {
event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret)
} catch (err) {
response.status(400).send(`Webhook Error: ${err.message}`)
return
}
// Handle the event
switch (event.type) {
case 'checkout.session.completed':
const checkoutSessionCompleted = event.data.object
console.log(checkoutSessionCompleted )
break
default:
console.log(`Unhandled event type ${event.type}`)
}
// Return a 200 response to acknowledge receipt of the event
response.send()
},
)`
which one is not working?
did the url change of your ngrok?
Yeah I have to setup every time I use it because it always give different url
ngrok url
you don't really need to do that since you already are using Stripe CLI
I don't see why you need both?
I dont need both I was previously working fine with ngrok. I need the details of transaction like amount etc. so I was paying using stripe checkout page
stripe cli just triggers that event right?
I can't get details like email or amout paid
Stripe CLI will forward all events
it depends on your code
if you want to listen to other events than checkout.session.completed you need to add more cases in your switch statement
to handle other event types
or if you need more info from the checkout session then you need to write that code yourself
Let me explain I am creating a payment link and doing payment for a product lets say 100$ so I want that details in my backend
ok