Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda