server v1.0.9 (full featured)

This commit is contained in:
2020-10-04 17:24:05 +02:00
parent 3dbbe4b1ba
commit 782b404da1
8 changed files with 163 additions and 6 deletions

View File

@@ -9,6 +9,8 @@ import {
changeLunchMenu,
changeLunchMenuSet,
fetchUser,
initializePayment,
renewSubscription,
} from "../services/databaseServices.js";
import {
decodeAndSanitize,
@@ -159,4 +161,23 @@ router.post("/delete", async (req, res) => {
}
});
// ACTIVATE SUBSCRIPTION
router.post("/subscription", async (req, res) => {
try {
const token = req.headers["x-auth-token"];
const user = validateUserToken(token);
await validateRestaurant(req.body.restaurantId);
/* const response = await initializePayment(
req.body.restaurantId,
req.body.userData,
req.body.type
); */
await renewSubscription(req.body.restaurantId, req.body.type);
res.send(200);
} catch (error) {
handleError(error, res);
}
});
export default router;