Skip to content

Commit

Permalink
backend/feat/payment_related_fcm
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh Pandey1 authored and piyushKumar-1 committed Jun 24, 2023
1 parent 487b988 commit 2586f36
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =>
Expand Down
23 changes: 23 additions & 0 deletions lib/mobility-core/src/Kernel/Types/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2586f36

Please sign in to comment.