Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
how to make a payment gateway for cart with multiple items in react

I am using razorpay api as a payment gateway for my shopping website and I am stuck at creating multiple orders

it works perfectly fine when I order single product but when I try to checkout from cart where there are multiple product added, I get stuck about what to do for amount and description field because it sends array of product while its send single product when its ordered directly.

app.post("/payment", async (req, res) => {
  try {
    const { product } = req.body;
    console.log("product");
    const amount = product.price * 100;
    const currency = "INR";
    const receipt = product.id;
    const notes = { desc: product.desc };

    instance.orders.create({ amount, currency, receipt, notes }),
      (err, order) => {
        if (error) {
          return res.status(500).json({ err });
        }
        return res.status(200).json({ order });
      };
  } catch (err) {
    console.log(err);
  }
  res.json(res);
});

when I order directly

{
 b_name: "siyaram",
 id: 9,
 p_color: "white",
 p_img: {type: 'Buffer', data: Array(5771)},
 p_name: "kurta",
 p_price: 1000,
 p_size: "s m l"
}

when I order from cart

[
 {
  b_name: "raymond,
  id: 9,
  p_color: "yellow",
  p_img: {type: 'Buffer', data: Array(5771)},
  p_name: "kurta",
  p_price: 1000,
  p_size: "s m l"
 },
 {
  b_name: "peter England",
  id: 9,
  p_color: "red",
  p_img: {type: 'Buffer', data: Array(5771)},
  p_name: "kurta",
  p_price: 1300,
  p_size: "s m l"
 }
]

this throws an error cause here I have multiple product.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda