Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Verify a FreshBooks webhook
const xml = require('xml');
module.exports = app => {
//processes the webhook for when a new invoice is created
app.post('/webhooks/new-invoice', async (req, res) => {
try {
// debugging
console.log(req.body);
const { name, verifier, object_id } = req.body;
const xmlResponse = xml([
{
request: [
{ _attr: { method: name } },
{ callback: [{ callback_id: object_id }, { verifier }] }
]
}
]);
// debugging
console.log(xmlResponse);
res.set('Content-Type', 'application/xml');
res.send(xmlResponse);
} catch (error) {
res.status(400).send(error);
}
});
};
@magician11

This comment has been minimized.

Copy link
Owner Author

commented Jun 14, 2018

Attempting to verify a webhook for FreshBooks from these docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.