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

151
Views
include metadata in stripe checkout session

I am using the pre-built stripe checkout session in node.js. here's my function:

app.get('/create-checkout-session', async (req, res) => {
    let customer = {
        price: req.query.price,
        quantity: req.query.quantity,
        page: req.query.page,
        email: req.query.email,
        name: req.query.name
    }

    // insertIntoDbPreCheckout(customer, req, res)

    let successurl = 'http://localhost:1111/' + customer.page + ''
    let failedurl = 'http://localhost:1111/' + customer.page + ''
  const session = await stripe.checkout.sessions.create({
    payment_method_types: ['card'],
    metadata: {
      'description': customer.page
    },
    customer_email: customer.email,
    line_items: [
      {
        price_data: {
          currency: 'cad',
          product_data: {
            name: customer.page,
          },
          unit_amount: customer.price,
        },
        quantity: customer.quantity,
      },
    ],
    mode: 'payment',
    success_url: successurl,
    cancel_url: failedurl,
  })

  res.redirect(303, session.url);
});

i am trying to pass METADATA through, but it isn't letting me.

I cannot find anything online that shows me how to do this, and it is not working no matter what I try. How can i fix this?

edit:

when i log the customers, it shows like this:

     email: 'uuu@u.com',
  invoice_prefix: '9FC11B6D',
  invoice_settings: { custom_fields: null, default_payment_method: null, footer: null },
  livemode: false,
  metadata: {},

as you can see, metadata is empty

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Based on the updated question, this is expected. The metadata you've provided is on the Checkout session itself. You're examining the Customer object created by the Checkout session, which does not have metadata (yet).

You can add customer metadata if you want to, by updating the customer:

const customer = await stripe.customers.update(
  'cus_123',
  {metadata: {order_id: '6735'}}
);

Existing metadata would be on the Checkout session object.

about 4 years ago · Juan Pablo Isaza Report
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!