diff --git a/lib/mobility-core/src/Kernel/External/Notification/FCM/Types.hs b/lib/mobility-core/src/Kernel/External/Notification/FCM/Types.hs index 7b653e866..abf96da7f 100644 --- a/lib/mobility-core/src/Kernel/External/Notification/FCM/Types.hs +++ b/lib/mobility-core/src/Kernel/External/Notification/FCM/Types.hs @@ -116,6 +116,8 @@ data FCMNotificationType | NEW_MESSAGE | REFERRAL_ACTIVATED | CHAT_MESSAGE + | PAYMENT_PENDING + | PAYMENT_OVERDUE deriving (Show, Eq, Read, Generic, ToJSON, FromJSON) deriving (PrettyShow) via Showable FCMNotificationType 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 0bab51e2d..c41c16498 100644 --- a/lib/mobility-core/src/Kernel/External/Payment/Interface/Juspay.hs +++ b/lib/mobility-core/src/Kernel/External/Payment/Interface/Juspay.hs @@ -98,6 +98,6 @@ orderStatusWebhook :: (OrderStatusResp -> Text -> m AckResponse) -> BasicAuthData -> Value -> - m AckResponse + m (Maybe Juspay.OrderStatusContent) orderStatusWebhook paymentConfig orderStatusHandler authData val = do Juspay.orderStatusWebhook paymentConfig (orderStatusHandler . mkOrderStatusResp . (.content.order)) authData val diff --git a/lib/mobility-core/src/Kernel/External/Payment/Juspay/Webhook.hs b/lib/mobility-core/src/Kernel/External/Payment/Juspay/Webhook.hs index 190c7ea84..0a8d29e55 100644 --- a/lib/mobility-core/src/Kernel/External/Payment/Juspay/Webhook.hs +++ b/lib/mobility-core/src/Kernel/External/Payment/Juspay/Webhook.hs @@ -36,7 +36,7 @@ orderStatusWebhook :: (Juspay.WebhookReq -> Text -> m AckResponse) -> BasicAuthData -> Value -> - m AckResponse + m (Maybe Juspay.OrderStatusContent) orderStatusWebhook paymentConfig orderStatusHandler authData val = do withLogTag "webhookPaymentOrderStatus" $ do let respDump = encodeToText val @@ -45,10 +45,10 @@ orderStatusWebhook paymentConfig orderStatusHandler authData val = do DAT.Success (resp :: Juspay.WebhookReq) -> do void $ verifyAuth paymentConfig authData void $ orderStatusHandler resp respDump - pure Ack + pure (Just resp.content) DAT.Error err -> do logInfo $ "OrderStatus Parsing failed :: " <> show err - pure Ack + pure Nothing verifyAuth :: EncFlow m r => diff --git a/lib/mobility-core/src/Kernel/Types/Error.hs b/lib/mobility-core/src/Kernel/Types/Error.hs index a5e06b9a3..cee7b13f6 100644 --- a/lib/mobility-core/src/Kernel/Types/Error.hs +++ b/lib/mobility-core/src/Kernel/Types/Error.hs @@ -986,3 +986,26 @@ instance IsHTTPError PaymentOrderError where PaymentOrderDoesNotExist _ -> E400 instance IsAPIError PaymentOrderError + +data DriverFeeError + = DriverFeeNotFound Text + | DriverFeeAlreadySettled Text + deriving (Eq, Show, IsBecknAPIError) + +instanceExceptionWithParent 'HTTPException ''DriverFeeError + +instance IsBaseError DriverFeeError where + toMessage = \case + DriverFeeNotFound driverFeeId -> Just $ "DriverFee with id \"" <> show driverFeeId <> "\"not found. " + DriverFeeAlreadySettled driverFeeId -> Just $ "DriverFee with id \"" <> show driverFeeId <> "\"is already settled." + +instance IsHTTPError DriverFeeError where + toErrorCode = \case + DriverFeeNotFound _ -> "DRIVER_FEE_NOT_FOUND" + DriverFeeAlreadySettled _ -> "DRIVER_FEE_ALREDAY_SETTLED" + + toHttpCode = \case + DriverFeeNotFound _ -> E500 + DriverFeeAlreadySettled _ -> E400 + +instance IsAPIError DriverFeeError