|
|
|
@ -136,6 +136,14 @@ router.post("/order", UserAuth, async (req: AuthedRequest, res: Response) => {
|
|
|
|
type: "startDate.invalid"
|
|
|
|
type: "startDate.invalid"
|
|
|
|
}]);
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emailQuery = await client.query(`
|
|
|
|
|
|
|
|
SELECT email FROM users WHERE id = $1;
|
|
|
|
|
|
|
|
`, [
|
|
|
|
|
|
|
|
req.user?.userId
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const email: string = emailQuery.rows[0].email;
|
|
|
|
|
|
|
|
|
|
|
|
const priceQuery = await client.query(`
|
|
|
|
const priceQuery = await client.query(`
|
|
|
|
SELECT hourly_price FROM trainers WHERE id = $1;
|
|
|
|
SELECT hourly_price FROM trainers WHERE id = $1;
|
|
|
|
`, [
|
|
|
|
`, [
|
|
|
|
@ -167,7 +175,8 @@ router.post("/order", UserAuth, async (req: AuthedRequest, res: Response) => {
|
|
|
|
expires_at: Math.floor(Date.now()/1000 + 60*31),
|
|
|
|
expires_at: Math.floor(Date.now()/1000 + 60*31),
|
|
|
|
mode: 'payment',
|
|
|
|
mode: 'payment',
|
|
|
|
success_url: `http://localhost:5173/orders`,
|
|
|
|
success_url: `http://localhost:5173/orders`,
|
|
|
|
cancel_url: `http://localhost:5173`
|
|
|
|
cancel_url: `http://localhost:5173`,
|
|
|
|
|
|
|
|
customer_email: email
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const insertQuery = await client.query(`
|
|
|
|
const insertQuery = await client.query(`
|
|
|
|
|