diff --git a/.env b/.env index e58a457..8367ad9 100644 --- a/.env +++ b/.env @@ -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 diff --git a/.env.development b/.env.development index c92a206..2cc0b56 100644 --- a/.env.development +++ b/.env.development @@ -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 diff --git a/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts b/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts index 89c8dc3..6ee8e5d 100644 --- a/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts +++ b/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts @@ -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) {