From 2d2873c4cfb026bd477f794322d5315c9ad71528 Mon Sep 17 00:00:00 2001 From: Aadil Ahmed Date: Wed, 18 Dec 2024 09:25:04 +0000 Subject: [PATCH 1/3] =?UTF-8?q?For=20reference=20use=20Orbit=20=E2=86=92?= =?UTF-8?q?=20previous=20webhook=20=E2=86=92=20payment=20=E2=86=92=20gener?= =?UTF-8?q?ated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/middlewares/services/SubmitService/SubmitService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/middlewares/services/SubmitService/SubmitService.ts b/api/src/middlewares/services/SubmitService/SubmitService.ts index 8d650861..a113c3c6 100644 --- a/api/src/middlewares/services/SubmitService/SubmitService.ts +++ b/api/src/middlewares/services/SubmitService/SubmitService.ts @@ -47,7 +47,7 @@ export class SubmitService { const formFields = flattenQuestions(questions); const answers = answersHashMap(formFields); const { pay, type } = metadata; - const reference = metadata?.pay?.reference ?? this.generateId(); + const reference = metadata?.externalReference ?? metadata?.internalReference ?? metadata?.pay?.reference ?? this.generateId(); const caseServiceName = getCaseServiceName(type); if (pay) { pay.total = fees?.total; From dcbda2825e2c4d25c7c2e065e0f809116ce306e4 Mon Sep 17 00:00:00 2001 From: Aadil Ahmed Date: Wed, 18 Dec 2024 09:27:39 +0000 Subject: [PATCH 2/3] Email case team only when there's no external reference --- .../middlewares/services/SubmitService/SubmitService.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/src/middlewares/services/SubmitService/SubmitService.ts b/api/src/middlewares/services/SubmitService/SubmitService.ts index a113c3c6..8d172083 100644 --- a/api/src/middlewares/services/SubmitService/SubmitService.ts +++ b/api/src/middlewares/services/SubmitService/SubmitService.ts @@ -61,8 +61,12 @@ export class SubmitService { type, metadata, }); - const caseProcessJob = await caseService.sendToProcessQueue(processQueueData); - this.logger.info({ reference, caseProcessJob }, `SES_PROCESS job queued successfully for ${reference}`); + + // only email case team when there is no external reference (i.e. from Orbit) indicating a submission failure there + if (!metadata?.externalReference) { + const caseProcessJob = await caseService.sendToProcessQueue(processQueueData); + this.logger.info({reference, caseProcessJob}, `SES_PROCESS job queued successfully for ${reference}`); + } const userProcessJob = await this.userService.sendToProcessQueue(answers, { reference, payment: metadata.pay, type, postal: metadata.postal }); From 1e177fff4b54c80deadc68bbfc4c8214b25d4f96 Mon Sep 17 00:00:00 2001 From: Aadil Ahmed Date: Wed, 18 Dec 2024 14:31:42 +0000 Subject: [PATCH 3/3] Allow null fees --- api/src/middlewares/validate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/middlewares/validate.ts b/api/src/middlewares/validate.ts index be57d2ce..858b22fe 100644 --- a/api/src/middlewares/validate.ts +++ b/api/src/middlewares/validate.ts @@ -19,7 +19,7 @@ const questionSchema = joi.object().keys({ const webhookOutputSchema = joi.object().keys({ name: joi.string().required(), questions: joi.array().items(questionSchema).required(), - fees: joi.object().optional(), + fees: joi.object().optional().allow(null), metadata: joi.object({ pay: joi .object({