@@ -46,20 +46,26 @@ instance FromJSON TransactionStatus where
4646data PaymentFailure = CVVFailed -- ^ CVV verification failure
4747 | CardInvalid -- ^ Credit card details are invalid
4848 | InvalidAmount -- ^ Money amount is invalid
49+ | GeneralDecline -- ^ They just decline
4950 | LocalTransaction -- ^ Special case for transactions that were registered but did't go through somehow.
51+ | OtherProcessingError Text -- ^ Some other processing error with 422 code
5052 deriving (Eq, Show)
5153
5254describeFailure :: PaymentFailure -> Text
5355describeFailure CVVFailed = "CVV authorisation failure"
5456describeFailure CardInvalid = "Invalid credit card details"
5557describeFailure InvalidAmount = "Invalid amount of money requested"
58+describeFailure GeneralDecline = "General card decine"
5659describeFailure LocalTransaction = "Transaction registered but not processed. Consult with payment processor."
60+describeFailure (OtherProcessingError txt) = "Transaction declined due to other error: " <> txt
5761
5862-- | Guess failure type from HTTP code and supplied error string.
5963guessFailure :: Int -> Text -> Maybe PaymentFailure
6064guessFailure 422 "Error code D2020. CVV2 verification failed." = Just CVVFailed
6165guessFailure 422 "Error code D2005. Invalid Card." = Just CardInvalid
6266guessFailure 422 "Amount field don't allow a value greater than $999,999.99" = Just InvalidAmount
67+guessFailure 422 "Error code D2999. General CardAuth Decline." = Just GeneralDecline
68+guessFailure 422 txt = Just (OtherProcessingError txt)
6369guessFailure _ _ = Nothing
6470
6571-- | Error response from Connexpay