diff --git a/server/intellipay/lib/handleInvoiceBasedPayment.js b/server/intellipay/lib/handleInvoiceBasedPayment.js index 21e4500a6..d5fc97b9c 100644 --- a/server/intellipay/lib/handleInvoiceBasedPayment.js +++ b/server/intellipay/lib/handleInvoiceBasedPayment.js @@ -107,18 +107,25 @@ const handleInvoiceBasedPayment = async (values, logger, logMeta, res) => { }); // Create payment response record - const responseResults = await gqlClient.request(INSERT_PAYMENT_RESPONSE, { - paymentResponse: { - amount: values.total, - bodyshopid: bodyshop.id, - paymentid: paymentResult.id, - jobid: job.id, - declinereason: "Approved", - ext_paymentid: values.paymentid, - successful: true, - response: values - } - }); + const responseResults = await gqlClient + .request(INSERT_PAYMENT_RESPONSE, { + paymentResponse: { + amount: values.total, + bodyshopid: bodyshop.id, + paymentid: paymentResult.insert_payments.returning[0].id, + jobid: job.id, + declinereason: "Approved", + ext_paymentid: values.paymentid, + successful: true, + response: values + } + }) + .catch((err) => { + logger.log("intellipay-postback-invoice-response-error", "ERROR", "api", null, { + err, + ...logMeta + }); + }); logger.log("intellipay-postback-invoice-response-success", "DEBUG", "api", null, { responseResults, diff --git a/server/notifications/scenarioParser.js b/server/notifications/scenarioParser.js index ddf1ff103..aebec8205 100644 --- a/server/notifications/scenarioParser.js +++ b/server/notifications/scenarioParser.js @@ -63,7 +63,9 @@ const scenarioParser = async (req, jobIdField) => { } if (!jobId) { - logger.log(`No jobId found using path "${jobIdField}", skipping notification parsing`, "info", "notifications"); + if (process?.env?.NODE_ENV === "development") { + logger.log(`No jobId found using path "${jobIdField}", skipping notification parsing`, "info", "notifications"); + } return; } @@ -88,7 +90,9 @@ const scenarioParser = async (req, jobIdField) => { // Exit early if no job watchers are found for this job if (isEmpty(jobWatchers)) { - logger.log(`No watchers found for jobId "${jobId}", skipping notification parsing`, "info", "notifications"); + if (process?.env?.NODE_ENV === "development") { + logger.log(`No watchers found for jobId "${jobId}", skipping notification parsing`, "info", "notifications"); + } return; } @@ -130,11 +134,13 @@ const scenarioParser = async (req, jobIdField) => { // Exit early if no matching scenarios are identified if (isEmpty(matchingScenarios)) { - logger.log( - `No matching scenarios found for jobId "${jobId}", skipping notification dispatch`, - "info", - "notifications" - ); + if (process?.env?.NODE_ENV === "development") { + logger.log( + `No matching scenarios found for jobId "${jobId}", skipping notification dispatch`, + "info", + "notifications" + ); + } return; } @@ -157,11 +163,13 @@ const scenarioParser = async (req, jobIdField) => { // Exit early if no notification associations are found if (isEmpty(associationsData?.associations)) { - logger.log( - `No notification associations found for jobId "${jobId}", skipping notification dispatch`, - "info", - "notifications" - ); + if (process?.env?.NODE_ENV === "development") { + logger.log( + `No notification associations found for jobId "${jobId}", skipping notification dispatch`, + "info", + "notifications" + ); + } return; } @@ -196,11 +204,13 @@ const scenarioParser = async (req, jobIdField) => { // Exit early if no scenarios have eligible watchers after filtering if (isEmpty(finalScenarioData?.matchingScenarios)) { - logger.log( - `No eligible watchers after filtering for jobId "${jobId}", skipping notification dispatch`, - "info", - "notifications" - ); + if (process?.env?.NODE_ENV === "development") { + logger.log( + `No eligible watchers after filtering for jobId "${jobId}", skipping notification dispatch`, + "info", + "notifications" + ); + } return; } @@ -259,7 +269,9 @@ const scenarioParser = async (req, jobIdField) => { } if (isEmpty(scenariosToDispatch)) { - logger.log(`No scenarios to dispatch for jobId "${jobId}" after building`, "info", "notifications"); + if (process?.env?.NODE_ENV === "development") { + logger.log(`No scenarios to dispatch for jobId "${jobId}" after building`, "info", "notifications"); + } return; }