git.iko.soy/typeable/connexpay
on master help sign in
Pass the exact error message in PaymentFailure (#5)
commit94989485ecc2e46c344903aab15e45f7f2c78e57 authorYuras <shumovichy@gmail.com> dateMon 7 Apr 2025, 11:34 (2 years ago) parent1e820f2
3 files changed+3−3
connexpay/src/Web/Connexpay/Data.hs+1−1 connexpay/src/Web/Connexpay/Payments.hs+1−1 connexpay/src/Web/Connexpay/Types.hs+1−1
connexpay/src/Web/Connexpay/Data.hs+1−1
@@ -90,7 +90,7 @@ data ConnectionError = ParseError String
9090-- * Payment failure means Connexpay returned an error and the payment wasn't authorised.
9191-- No exception here, this must be handled as usual.
9292data ConnexpayError = ConnectionError ConnectionError
93− | PaymentFailure PaymentFailure
93+ | PaymentFailure PaymentFailure (Maybe Text)
9494 deriving (Show)
9595
9696instance Exception ConnexpayError
connexpay/src/Web/Connexpay/Payments.hs+1−1
@@ -141,7 +141,7 @@ authorisePayment cc amt invoice vendor =
141141 -- Also, when I asked Ken from Connexpay about this,
142142 -- he told me he had never seen this status before.
143143 when (rbody.status == TransactionCreatedLocal) $
144− throwError (PaymentFailure LocalTransaction)
144+ throwError (PaymentFailure LocalTransaction Nothing)
145145 pure rbody
146146 where body = execWriter $
147147 do tell [ "Card" .= cc ]
connexpay/src/Web/Connexpay/Types.hs+1−1
@@ -43,7 +43,7 @@ instance MonadHttp ConnexpayM where
4343 handleHttpException (VanillaHttpException (InvalidUrlException url why)) = throwError (ConnectionError $ InvalidUrl url why)
4444 handleHttpException (VanillaHttpException (HttpExceptionRequest _ (StatusCodeException resp bs)))
4545 | Just err <- decodeStrict @ErrorMessage bs
46− , Just f <- guessFailure (statusCode $ responseStatus resp) err.message = throwError (PaymentFailure f)
46+ , Just f <- guessFailure (statusCode $ responseStatus resp) err.message = throwError (PaymentFailure f (Just err.message))
4747 handleHttpException (VanillaHttpException (HttpExceptionRequest _ c)) = throwError (ConnectionError $ HttpFailure c)
4848
4949 getHttpConfig =