diff --git a/src/config.ts b/src/config.ts index c789693e..56923d8a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -177,7 +177,8 @@ const defaultConfig: IoDevServerConfig = { }, features: { payments: { - numberOfTransactions: 12 + numberOfTransactions: 12, + hideReceiptResponseCode: 400 }, bonus: { cgn: { diff --git a/src/features/payments/routers/notices.ts b/src/features/payments/routers/notices.ts index 02ad348a..f2839e4c 100644 --- a/src/features/payments/routers/notices.ts +++ b/src/features/payments/routers/notices.ts @@ -1,13 +1,15 @@ import * as O from "fp-ts/lib/Option"; import { pipe } from "fp-ts/lib/function"; -import NoticesDB from "../persistence/notices"; import { sendFileFromRootPath } from "../../../utils/file"; +import NoticesDB from "../persistence/notices"; import { NoticeListWrapResponse } from "../../../../generated/definitions/pagopa/transactions/NoticeListWrapResponse"; +import { ioDevServerConfig } from "../../../config"; import { addNoticesHandler } from "./router"; const CONTINUATION_TOKEN_HEADER = "x-continuation-token"; const DEFAULT_SIZE = 10; +const { hideReceiptResponseCode } = ioDevServerConfig.features.payments; addNoticesHandler("get", "/paids", (req, res) => { const size = req.query.size ? Number(req.query.size) : DEFAULT_SIZE; @@ -87,3 +89,17 @@ addNoticesHandler("get", "/paids/:eventId/pdf", (req, res) => { ) ); }); + +addNoticesHandler("post", "/paids/:eventId/disable", (req, res) => { + pipe( + req.params.eventId, + O.fromNullable, + O.fold( + () => res.sendStatus(400), + eventId => { + NoticesDB.removeUserNotice(eventId); + return res.sendStatus(hideReceiptResponseCode); + } + ) + ); +}); diff --git a/src/types/config.ts b/src/types/config.ts index 90d041e4..ffd2018b 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -192,7 +192,9 @@ export const IoDevServerConfig = t.interface({ t.interface({ payments: t.interface({ // the number of transactions to generate at the beginning - numberOfTransactions: t.number + numberOfTransactions: t.number, + // the response code when hiding a receipt + hideReceiptResponseCode: HttpResponseCode }), bonus: t.interface({ // defines the special configuration for cgn eligibility