mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 00:08:37 +01:00
fix bugs
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user