import { Webhook } from 'svix';
import * as express from 'express';
const app = express();
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
const payload = req.body.toString();
const headers = req.headers as Record<string, string>;
const secret = 'whsec_...'; // Your Webhook Secret from Solifyn Dashboard
const wh = new Webhook(secret);
try {
// Returns the parsed and verified payload object
const event = wh.verify(payload, headers);
console.log('Webhook verified successfully:', event);
res.status(200).send('OK');
} catch (err: any) {
console.error('Invalid signature:', err.message);
res.status(400).send('Invalid signature');
}
});