This commit is contained in:
Emily
2025-04-16 17:13:19 +02:00
parent 946f9d4d32
commit f631c29fb2
12 changed files with 59 additions and 60 deletions

View File

@@ -17,11 +17,23 @@ console.log('Stripe started in', STRIPE_TESTMODE ? 'TESTMODE' : 'LIVEMODE');
const app = express();
const TOKEN = process.env.TOKEN;
if (!TOKEN || TOKEN.length == 0) {
console.log('TOKEN not set');
process.exit();
}
app.use((req, res, next) => {
const token = req.header('x-litlyx-token');
if (token != TOKEN) {
res.status(403).json({ error: 'token not valid' });
return;
}
console.log(req.path);
next();
})
});
app.use('/webhook', webhookRouter);
app.use('/payment', paymentRouter);

View File

@@ -146,4 +146,19 @@ paymentRouter.post('/update_customer_info', json(), async (req, res) => {
} catch (ex) {
res.status(500).json({ error: ex.message });
}
});
export const ZBodyDeleteCustomer = z.object({
customer_id: z.string(),
});
paymentRouter.post('/delete_customer', json(), async (req, res) => {
try {
const deleteCustomerData = ZBodyDeleteCustomer.parse(req.body);
await StripeService.deleteCustomer(deleteCustomerData.customer_id);
return sendJson(res, 200, { ok: true });
} catch (ex) {
res.status(500).json({ error: ex.message });
}
});