Fix checkout API

This commit is contained in:
Moe Poi ~ 2021-11-21 11:25:28 +07:00
parent efd61589ea
commit a9d1f8e9ee

View file

@ -327,6 +327,16 @@ router.post("/checkout", async (req, res) => {
});
} else {
const conn = db.connect();
conn.query(
"SELECT * FROM users WHERE token = ?",
[req.query.key],
async function (error, resp, fields) {
if (error) {
res.status(401);
res.json({
message: "Unauthorized",
});
} else {
var data = {
firstName: req.body.firstName,
lastName: req.body.lastName,
@ -342,7 +352,7 @@ router.post("/checkout", async (req, res) => {
logistic: req.body.logistic,
paymentMethod: '-',
data: req.body.data,
userId: 14,
userId: resp[0].id,
paid: '0',
status: 'pending'
};
@ -376,6 +386,9 @@ router.post("/checkout", async (req, res) => {
}
);
}
}
);
}
} else {
res.status(401);
res.json({