From b6bba0518e11d8485af6258a2eae159a4b9f0f4c Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:37:33 +0100 Subject: [PATCH] fix: setting 403 when notification fails (#1232) --- .../cartridge/adyen/webhooks/__tests__/notify.test.js | 2 +- .../int_adyen_SFRA/cartridge/adyen/webhooks/notify.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/__tests__/notify.test.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/__tests__/notify.test.js index ff25b2ade..0d67e310b 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/__tests__/notify.test.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/__tests__/notify.test.js @@ -9,7 +9,7 @@ beforeEach(() => { notify = adyen.notify; jest.clearAllMocks(); req = {}; - res = { render: jest.fn() }; + res = { render: jest.fn(), status: jest.fn(() => res)}; }); afterEach(() => { diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/notify.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/notify.js index 984811f46..1f45168e6 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/notify.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/webhooks/notify.js @@ -19,7 +19,7 @@ function notify(req, res, next) { const hmacKey = AdyenConfigs.getAdyenHmacKey(); const isHmacValid = handleHmacVerification(hmacKey, req); if (!status || !isHmacValid) { - res.render('/adyen/error'); + res.status(403).render('/adyen/error'); return {}; } Transaction.begin(); @@ -28,7 +28,7 @@ function notify(req, res, next) { Transaction.commit(); res.render('/notify'); } else { - res.render('/notifyError', { + res.status(403).render('/notifyError', { errorMessage: notificationResult.errorMessage, }); Transaction.rollback();