#nit_sin

1 messages ยท Page 1 of 1 (latest)

sleek patrolBOT
low flicker
#

๐Ÿ‘‹ happy to help

lunar jolt
#

it was working previously but now no its giving no response

low flicker
#

/webhook_endpints?

lunar jolt
low flicker
#

do you have an event ID?

lunar jolt
#

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

low flicker
#

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?

lunar jolt
#

yeah I am not using stripe cli

#

I am using ngrok to create a public url and forward that to localhost

low flicker
#

stripe listen --forward-to localhost:3001/webhook
this is Stripe CLI

lunar jolt
#

Also I am getting error like this

low flicker
#

this is not related and you can disregard that

#

would you mind sharing your code please?

lunar jolt
#

`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()

},
)`

low flicker
#

which one is not working?

lunar jolt
#

This was the endpoints last one was working fine until yesterday

#

for now none

low flicker
#

did the url change of your ngrok?

lunar jolt
#

Yeah I have to setup every time I use it because it always give different url

#

ngrok url

low flicker
#

you don't really need to do that since you already are using Stripe CLI

#

I don't see why you need both?

lunar jolt
#

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

low flicker
#

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

lunar jolt
#

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

low flicker
#

ok

lunar jolt
#

so that is why i am using ngrok to forwark the response to my localhost

#

and I can write my logic according to that

low flicker
#

you can use Stripe CLI for that

#

no need for ngrok