add env to turn off automatic medipost sending on montonio callback

This commit is contained in:
2025-09-10 06:32:25 +03:00
parent 0aea6b80d4
commit fa9895637d
3 changed files with 27 additions and 1 deletions

3
.env
View File

@@ -68,3 +68,6 @@ NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=
# Configure Medusa password secret for Keycloak users
MEDUSA_PASSWORD_SECRET=ODEwMGNiMmUtOGMxYS0xMWYwLWJlZDYtYTM3YzYyMWY0NGEzCg==
# False by default
MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=false

View File

@@ -26,6 +26,22 @@ EMAIL_PORT=1025 # or 465 for SSL
EMAIL_TLS=false
NODE_TLS_REJECT_UNAUTHORIZED=0
# MEDIPOST
MEDIPOST_URL=https://meditest.medisoft.ee:7443/Medipost/MedipostServlet
MEDIPOST_USER=trvurgtst
MEDIPOST_PASSWORD=SRB48HZMV
MEDIPOST_RECIPIENT=trvurgtst
MEDIPOST_MESSAGE_SENDER=trvurgtst
MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=true
#MEDIPOST_URL=https://medipost2.medisoft.ee:8443/Medipost/MedipostServlet
#MEDIPOST_USER=medreport
#MEDIPOST_PASSWORD=
#MEDIPOST_RECIPIENT=HTI
#MEDIPOST_MESSAGE_SENDER=medreport
#MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=false
# MEDUSA
MEDUSA_BACKEND_URL=http://localhost:9000
MEDUSA_BACKEND_PUBLIC_URL=http://localhost:9000

View File

@@ -30,10 +30,15 @@ const env = () => z
error: 'NEXT_PUBLIC_SITE_URL is required',
})
.min(1),
isEnabledDispatchOnMontonioCallback: z
.boolean({
error: 'MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK is required',
}),
})
.parse({
emailSender: process.env.EMAIL_SENDER,
siteUrl: process.env.NEXT_PUBLIC_SITE_URL!,
isEnabledDispatchOnMontonioCallback: process.env.MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK === 'true',
});
const sendEmail = async ({
@@ -205,7 +210,9 @@ export async function processMontonioCallback(orderToken: string) {
console.error("Missing email to send order result email", orderResult);
}
await sendOrderToMedipost({ medusaOrderId, orderedAnalysisElements });
if (env().isEnabledDispatchOnMontonioCallback) {
await sendOrderToMedipost({ medusaOrderId, orderedAnalysisElements });
}
return { success: true, orderId };
} catch (error) {