Skip to content

Commit 143c4e6

Browse files
committed
fix(woovi): End webhook handler with status 200 always than body is valid and authorization passes
Prevent disabling webhooks with transactions for different orders (not found)
1 parent 276dc6e commit 143c4e6

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/apps/woovi/src/woovi-create-transaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default async (modBody: AppModuleBody<'create_transaction'>) => {
3232
message: 'AppID não configurado (lojista deve configurar o aplicativo)',
3333
};
3434
}
35-
const wooviKeyId = '2-' + `${WOOVI_APP_ID}`.substring(0, 6) + `${WOOVI_APP_ID}`.slice(-3);
35+
const wooviKeyId = '3-' + `${WOOVI_APP_ID}`.substring(0, 6) + `${WOOVI_APP_ID}`.slice(-3);
3636

3737
const {
3838
order_id: orderId,

packages/apps/woovi/src/woovi-events.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const handleWebhook = async (req: Request, res: Response) => {
5151
logger.warn('Woovi webhook missing correlationID', { body });
5252
return res.sendStatus(400);
5353
}
54-
logger.info(`> Woovi notification: ${event}`, { correlationID });
54+
logger.info(`> Woovi notification: ${event} for ${correlationID}`);
5555
const status = parseWooviStatus(event);
5656
if (!status) {
5757
logger.info(`Ignoring Woovi event: ${event}`);
@@ -81,8 +81,8 @@ const handleWebhook = async (req: Request, res: Response) => {
8181
try {
8282
const orders = await listOrdersByTransaction(correlationID);
8383
if (!orders.length) {
84-
logger.warn('Order not found for Woovi charge', { correlationID });
85-
return res.sendStatus(404);
84+
logger.warn(`Order not found for Woovi charge ${correlationID}`);
85+
return res.status(200).send();
8686
}
8787

8888
await Promise.all(orders.map(async (order) => {
@@ -108,7 +108,7 @@ const handleWebhook = async (req: Request, res: Response) => {
108108
logger.info(`Updated order ${orderId} to ${status}`);
109109
}));
110110

111-
return res.sendStatus(200);
111+
return res.status(200).send();
112112
} catch (err: any) {
113113
logger.error('Woovi webhook error', err);
114114
return res.status(500).send({

0 commit comments

Comments
 (0)