Created
August 1, 2020 20:38
-
-
Save yurist38/7d53e82bb489b52dd743ba1107941c81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { stripe_secret_key, stripe_webhook_secret } = privateConfig; | |
const stripe = new Stripe(stripe_secret_key); | |
let event: events.IEvent | undefined; | |
try { | |
const sig = req.headers['stripe-signature'] as string; | |
const reqBody = req.rawBody.toString(); | |
event = stripe.webhooks.constructEvent(reqBody, sig, stripe_webhook_secret); | |
} catch (err) { | |
res.status(400).send(`Webhook Error: ${err.message}`); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment