include description in stripe checkout session node.js

Viewed 70

I have this:

    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'],
    payment_intent_data: {
      '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 through a description, which will act as the product name, and a few other things, just some informaiton. But i cannot figure out how to do so. I tried the method above, as well as other methods, but it all returns empty. how can i fix this?

0 Answers
Related