Skip to content

Commit bbdd24b

Browse files
committed
fix(vindi-webhook): handling test events with 200 response [#64]
fixes #64
1 parent 5836ed2 commit bbdd24b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

functions/routes/vindi/webhook.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ exports.post = ({ appSdk, admin }, req, res) => {
66
// https://atendimento.vindi.com.br/hc/pt-br/articles/203305800-O-que-s%C3%A3o-e-como-funcionam-os-Webhooks-
77
const vindiEvent = req.body && req.body.event
88
if (vindiEvent && vindiEvent.data && vindiEvent.type) {
9-
const data = vindiEvent.data.id ? vindiEvent.data
9+
if (vindiEvent.type === 'test') {
10+
return res.sendStatus(200)
11+
}
12+
13+
const data = vindiEvent.data.id
14+
? vindiEvent.data
1015
: (vindiEvent.data.bill || vindiEvent.data.charge)
1116
if (data && data.id) {
1217
const collectionRef = admin.firestore().collection('charges')

0 commit comments

Comments
 (0)