1

I only need to do a get request with this webhook. Stripe is indeed sending information to the webhook i just cant figure out how to retrieve the information in Node.JS. I know i need to setup a webhook listener to watch for requests however i cannot find any good useful tutorials. I am currently using hook.io as my webhook vendor. Does anyone have any ideas on how to do this?

3 Answers 3

1

First thing first (I'm a bit of a purist) Node.js is not a language but a runtime environment. So I'll assume that you're using Express.js as your web framework.

Stripe Dashboard

Then you'll have to Add an endpoint, select the appropriates events, and you'll be good to go. Stripe will POST events to your endpoint. You'll be then able to parse the body of the request to handle them.

enter image description here Edit : domain won't be ngrok.io but something like mysubdomain.ngrok.io

then on your app.js (or any router)


app.post('/my-endpoint', (req, res, next) => {
  // Do whatever you want with req.body
  // Fetching a database, send a email to customer... 

  res.sendStatus(200) 
  // ALWAYS answer 2XX to Stripe otherwise it'll be considered as failed on Stripe's end.
})

If you're new to webhook, I highly suggest you to download Stripe CLI, and use Ngrok to test webhooks locally before going live. I'm currently writing a dev.to post about Stripe's webhooks, I'll post it once done.

Sign up to request clarification or add additional context in comments.

Comments

0

You can find an Express-based example here: https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing/node-express

Comments

0

Sorry for posting this answer late, I figured this out awhile ago. If you visit this link and follow it step by step it worked like a charm for me. Just create a new PHP file on your webserver copy and paste the code and make the changes necessary to fit your needs.

https://stripe.com/docs/webhooks/integration-builder

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.