feat(server): listen to Plaid webhooks

This commit is contained in:
Ahmed Bouhuolia
2024-02-14 17:11:07 +02:00
parent 706a324121
commit 1fd8a53ed1
8 changed files with 71 additions and 51 deletions

View File

@@ -16,7 +16,6 @@ export class PlaidBankingController extends BaseController {
router.post('/link-token', this.linkToken.bind(this));
router.post('/exchange-token', this.exchangeToken.bind(this));
router.post('/webhooks', this.webhooks.bind(this));
return router;
}
@@ -36,7 +35,7 @@ export class PlaidBankingController extends BaseController {
}
/**
*
* Exchanges the given public token.
* @param {Request} req
* @param {response} res
* @returns {Response}
@@ -51,21 +50,4 @@ export class PlaidBankingController extends BaseController {
});
return res.status(200).send({});
}
public async webhooks(req: Request, res: Response) {
const { tenantId } = req;
const {
webhook_type: webhookType,
webhook_code: webhookCode,
item_id: plaidItemId,
} = req.body;
await this.plaidApp.webhooks(
tenantId,
webhookType,
plaidItemId,
webhookCode
);
return res.status(200).send({ code: 200, message: 'ok' });
}
}