From 08521a672395ddb20333a28be5703573781ec3f9 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Mon, 7 Sep 2026 12:58:20 +0530 Subject: [PATCH] added useWebhookConfig field in juspayCfg --- .../External/Payment/Interface/Juspay.hs | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/mobility-core/src/Kernel/External/Payment/Interface/Juspay.hs b/lib/mobility-core/src/Kernel/External/Payment/Interface/Juspay.hs index ceffe0323..7e1914caa 100644 --- a/lib/mobility-core/src/Kernel/External/Payment/Interface/Juspay.hs +++ b/lib/mobility-core/src/Kernel/External/Payment/Interface/Juspay.hs @@ -15,7 +15,7 @@ module Kernel.External.Payment.Interface.Juspay ( module Reexport, createOrder, - mkCreateOrderReq, + getCreateOrderReq, getCustomerOrCreateCustomer, getCustomer, orderStatus, @@ -73,20 +73,29 @@ createOrder :: createOrder config mRoutingId req = do let url = config.url merchantId = config.merchantId - clientId = fromMaybe merchantId config.pseudoClientId - cfgWebhookUrl = do - reqUrl <- req.webhookUrl - configPath <- config.webhookUrl - let baseHost = showBaseUrl reqUrl {baseUrlPath = ""} - normalizedPath = if T.isPrefixOf "/" configPath then configPath else "/" <> configPath - return $ baseHost <> normalizedPath logDebug $ "createOrder req: " <> show req apiKey <- decrypt config.apiKey - orderReq <- mkCreateOrderReq config.returnUrl config.autoRefundConflictThresholdMinutes cfgWebhookUrl clientId merchantId req + orderReq <- getCreateOrderReq config (Just False) req logDebug $ "createOrder mkCreateOrderReq: " <> show orderReq logDebug $ "createOrder splitSettlementDetails: " <> show req.splitSettlementDetails Juspay.createOrder url apiKey merchantId mRoutingId orderReq +getCreateOrderReq :: (MonadTime m, MonadThrow m, Log m) => JuspayCfg -> Maybe Bool -> CreateOrderReq -> m Juspay.CreateOrderReq +getCreateOrderReq config mbUseWebhookConfig req = do + let clientId = fromMaybe config.merchantId config.pseudoClientId + cfgWebhookUrl = do + reqUrl <- req.webhookUrl + configPath <- config.webhookUrl + let baseHost = showBaseUrl reqUrl {baseUrlPath = ""} + normalizedPath = if T.isPrefixOf "/" configPath then configPath else "/" <> configPath + separator = if T.isInfixOf "?" normalizedPath then "&" else "?" + taggedPath = + if mbUseWebhookConfig == Just True + then normalizedPath <> separator <> "useWebhookConfig=true" + else normalizedPath + return $ baseHost <> taggedPath + mkCreateOrderReq config.returnUrl config.autoRefundConflictThresholdMinutes cfgWebhookUrl clientId config.merchantId req + updateOrder :: ( Metrics.CoreMetrics m, EncFlow m r,