Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.stripeWebhook = async event => {
let err = null
try
{
const signature = event.headers["Stripe-Signature"]
const secret = (await client.fetchSecret({ SecretId: secretName })).SecretString
const eventReceived = stripe.webhooks.constructEvent(event.body, signature, secret)
await eventbridge.sendToEventBridge(process.env.EVENT_BRIDGE, eventReceived)
}
catch (e)
{
err = e
await sns.notifyFailure(e.message)
}
const body = err ? JSON.stringify(err) : ""
const statusCode = err ? 500 : 200
return { statusCode, body }
};