@@ -6,7 +6,6 @@ module Web.Connexpay.Payments.Types where
66import Data.Aeson
77import Data.Aeson.TH
88import Data.Fixed
9−import Data.Function
109import Data.Int (Int32)
1110import Data.Maybe
1211import Data.Text (Text)
@@ -117,30 +116,6 @@ instance ToJSON RiskData where
117116maskRiskData :: LogMasker RiskData
118117maskRiskData = id
119118
120−data AuthorizeResult
121− = Authorized AuthResponse
122− -- ^ Transaction has been created and authorized successfully
123− | Declined AuthResponse
124− -- ^ Transaction has been created, but not authorized,
125− -- e.g. declined by internal Connexpay fraud checks
126− | Ambiguous AuthResponse
127− -- ^ We can't interpret the result, e.g. wasProcess=true,
128− -- but transaction status is not approved.
129− -- Something for further investigation.
130− deriving stock (Show)
131−
132−postProcessAuthResponse :: AuthResponse -> AuthorizeResult
133−postProcessAuthResponse resp = resp & case (completed, statusOk) of
134− (True, True) -> Authorized
135− (False, False) -> Declined
136− _ -> Ambiguous
137− where
138− -- Connexpay documentation is not very clear about 'wasProcessed' semantics
139− -- when it is missing, so we are intentionally strict here with the idea
140− -- to warn about all 'Ambiguous' cases and adjust this code accordingly.
141− completed = resp.wasProcessed == Just True
142− statusOk = resp.status `elem` [TransactionApproved, TransactionApprovedWarning]
143−
144119data AuthResponse = AuthResponse
145120 { guid :: AuthOnlyGuid
146121 , status :: TransactionStatus
@@ -148,7 +123,6 @@ data AuthResponse = AuthResponse
148123 , processorResponseMessage :: Maybe Text
149124 , addressVerificationCode :: Maybe Text
150125 , cvvVerificationCode :: Maybe Text
151− , wasProcessed :: Maybe Bool
152126 } deriving stock (Show)
153127
154128-- | Transaction status in Connexpay
@@ -165,7 +139,7 @@ data TransactionStatus
165139 -- ^ Processor errored out
166140 | TransactionOther Text
167141 -- ^ In case they return something unexpected
168− deriving stock (Eq, Show)
142+ deriving stock (Show)
169143
170144instance FromJSON TransactionStatus where
171145 parseJSON = withText "TransactionStatus" $ pure . \case