diff --git a/server/src/routes/createOrder.ts b/server/src/routes/createOrder.ts index 639547a..368f0bd 100644 --- a/server/src/routes/createOrder.ts +++ b/server/src/routes/createOrder.ts @@ -136,6 +136,14 @@ router.post("/order", UserAuth, async (req: AuthedRequest, res: Response) => { 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(` 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), mode: 'payment', success_url: `http://localhost:5173/orders`, - cancel_url: `http://localhost:5173` + cancel_url: `http://localhost:5173`, + customer_email: email }); const insertQuery = await client.query(`