Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,18 @@ mkOrderStatusResp Juspay.OrderData {..} =
card = castCard <$> card,
splitSettlementResponse = mkSplitSettlementResponse <$> split_settlement_response,
offers = maybe Nothing mkOffersData offers,
txnDetail = castTxnDetail <$> txn_detail,
..
}

castUpi :: Juspay.Upi -> Upi
castUpi Juspay.Upi {..} = Upi {payerApp = payer_app, payerAppName = payer_app_name, txnFlowType = txn_flow_type, payerVpa = payer_vpa}

castCard :: Juspay.CardInfo -> CardInfo
castCard Juspay.CardInfo {..} = CardInfo {cardType = card_type, lastFourDigits = last_four_digits}
castCard Juspay.CardInfo {..} = CardInfo {cardType = card_type, lastFourDigits = last_four_digits, nameOnCard = name_on_card, cardBrand = card_brand, cardIsin = card_isin, cardIssuer = card_issuer}

castTxnDetail :: Juspay.TxnDetail -> TxnDetail
castTxnDetail Juspay.TxnDetail {..} = TxnDetail {gateway = gateway, surchargeAmount = realToFrac <$> surcharge_amount, taxAmount = realToFrac <$> tax_amount, netAmount = realToFrac <$> net_amount}

mkNotificationReq :: MandateNotificationReq -> Juspay.MandateNotificationReq
mkNotificationReq mandateNotificationReq =
Expand Down Expand Up @@ -641,6 +645,7 @@ mkWebhookOrderStatusResp now (eventName, Juspay.OrderAndNotificationStatusConten
card = castCard <$> justOrder.card,
splitSettlementResponse = mkSplitSettlementResponse <$> justOrder.split_settlement_response,
offers = maybe Nothing mkOffersData justOrder.offers,
txnDetail = castTxnDetail <$> justOrder.txn_detail,
..
}
(Nothing, Just justMandate, _, _) ->
Expand Down Expand Up @@ -695,6 +700,7 @@ mkWebhookOrderStatusResp now (eventName, Juspay.OrderAndNotificationStatusConten
splitSettlementResponse = Nothing,
effectiveAmount = Just $ realToFrac justTransaction.txn_amount,
offers = Nothing,
txnDetail = castTxnDetail <$> justTransaction.txn_detail,
..
}
(_, _, Nothing, _) -> BadStatusResp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,6 @@ mkOrderStatusResp response orderId =
card = Nothing,
splitSettlementResponse = Nothing,
effectiveAmount = Nothing,
offers = Nothing
offers = Nothing,
txnDetail = Nothing
}
18 changes: 16 additions & 2 deletions lib/mobility-core/src/Kernel/External/Payment/Interface/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ data OrderStatusResp
card :: Maybe CardInfo,
splitSettlementResponse :: Maybe SplitSettlementResponse,
effectiveAmount :: Maybe HighPrecMoney,
offers :: Maybe [Offer]
offers :: Maybe [Offer],
txnDetail :: Maybe TxnDetail
}
| MandateOrderStatusResp
{ eventName :: Maybe PaymentStatus,
Expand Down Expand Up @@ -313,7 +314,20 @@ data Upi = Upi

data CardInfo = CardInfo
{ lastFourDigits :: Maybe Text,
cardType :: Maybe Text
cardType :: Maybe Text,
nameOnCard :: Maybe Text,
cardBrand :: Maybe Text,
cardIsin :: Maybe Text,
cardIssuer :: Maybe Text
}
deriving stock (Show, Read, Eq, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)

data TxnDetail = TxnDetail
{ gateway :: Maybe Text,
surchargeAmount :: Maybe HighPrecMoney,
taxAmount :: Maybe HighPrecMoney,
netAmount :: Maybe HighPrecMoney
}
deriving stock (Show, Read, Eq, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ data OrderData = OrderData
refunds :: Maybe [RefundsData],
split_settlement_response :: Maybe SplitSettlementResponse,
effective_amount :: Maybe Double,
offers :: Maybe [Offer]
offers :: Maybe [Offer],
txn_detail :: Maybe TxnDetail
}
deriving stock (Show, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)
Expand Down Expand Up @@ -242,6 +243,15 @@ data PaymentGatewayResponse = PaymentGatewayResponse
deriving stock (Show, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)

data TxnDetail = TxnDetail
{ gateway :: Maybe Text,
surcharge_amount :: Maybe Double,
tax_amount :: Maybe Double,
net_amount :: Maybe Double
}
deriving stock (Show, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)

data MandateData = MandateData
{ mandate_status :: MandateStatus,
start_date :: Text,
Expand All @@ -264,7 +274,11 @@ data Upi = Upi

data CardInfo = CardInfo
{ card_type :: Maybe Text,
last_four_digits :: Maybe Text
last_four_digits :: Maybe Text,
name_on_card :: Maybe Text,
card_brand :: Maybe Text,
card_isin :: Maybe Text,
card_issuer :: Maybe Text
}
deriving stock (Show, Generic, Read, Eq)
deriving anyclass (FromJSON, ToJSON, ToSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ data WebhookTxnData = WebhookTxnData
links :: Maybe LinkData,
payer_vpa :: Maybe Text,
upi :: Maybe Upi,
card :: Maybe CardInfo
card :: Maybe CardInfo,
txn_detail :: Maybe TxnDetail
}
deriving stock (Show, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ createPayoutOrder config mRoutingId req = do
Payout.AccountDetails
{ name = customerName,
vpa = Just customerVpa,
mobileNo = Just customerPhone
mobileNo = Just customerPhone,
account = Nothing,
ifsc = Nothing
},
detailsType = Just Juspay.UPI_ID
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ $(mkBeamInstancesForEnum ''AccountDetailsType)
data AccountDetails = AccountDetails
{ name :: Text,
vpa :: Maybe Text,
mobileNo :: Maybe Text
mobileNo :: Maybe Text,
account :: Maybe Text,
ifsc :: Maybe Text
}
deriving (Show, Generic, ToSchema)
deriving anyclass (FromJSON, ToJSON)
Expand Down