From 08fb7fa2e25f67bed2401aba8156e13f8e4338e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaume=20Sol=C3=ADs?= Date: Thu, 18 Apr 2024 15:30:16 +0200 Subject: [PATCH] treure logs perque funcioni --- api/controller/Payment/payment.services.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/api/controller/Payment/payment.services.js b/api/controller/Payment/payment.services.js index d40341a..fed47bc 100644 --- a/api/controller/Payment/payment.services.js +++ b/api/controller/Payment/payment.services.js @@ -7,15 +7,17 @@ class PaymentServices { try { //parameters to return the products that will be purchased const { products, dateExpired, postalCode, customer, type } = req.body - const _products = await db.getProducts(dateExpired, postalCode) +// const _products = await db.getProducts(dateExpired, postalCode) - const productsFilter = _products[0].filter((item) => { - if (products.includes(item.itemFk)) { + /* const productsFilter = _products[0].filter((item) => { + if (products.includes(item.id)) { return item } - }); + });*/ - if (productsFilter.length !== products.length) { + const productsFilter = await db.getProductById(products[0]); + + if (productsFilter[0][0].length !== products.length) { return res.status(422).send({ data: { message: "Uno de los productos no existe." @@ -42,8 +44,8 @@ class PaymentServices { }, }) const order = await db.orderData_put(jsonOrderData); - //const orderFk = order[0][0].orderFk - const orderFk = jsonOrderData.customer.customerData.products[0].id; + const orderFk = order[0][0].catalogueFk; + //const orderFk = jsonOrderData.customer.customerData.products[0].id; if (type === "paypal") { const data = await payPalProviders.New(orderFk, price) @@ -102,4 +104,4 @@ class PaymentServices { } } -module.exports = new PaymentServices(); +module.exports = new PaymentServices(); \ No newline at end of file