Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
How to get metadata from stripe checkout session in webhook handler?

I'm trying to associate name in metadata with payment session and then access in webhook handler. How would I do that?

My code:

const session = await stripe.checkout.sessions.create({
    line_items: [
      {
        price: <priceid>,
        quantity: 1,
      },
    ],
    metadata: {
      nick: `${req.params.nick}`,
    },
    mode: "payment",
    success_url: `${process.env.DOMAIN}/success`,
    cancel_url: `${process.env.DOMAIN}/bany`,
  })

Webhook handler:

router.post(
  "/webhook",
  express.json({ type: "application/json" }),
  (request, response) => {
    const event = request.body

    // Handle the event
    switch (event.type) {
      case "checkout.session.completed":
        const data = <metadata from checkout session>
        console.log(data)
        break
      default:
        console.log(`Unhandled event type ${event.type}`)
    }

    response.json({ received: true })
  }
)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!