From 860596c74475a644310c53608ffafed36829291a Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Mon, 21 Sep 2020 10:46:37 -0400 Subject: [PATCH] remove unused imports --- src/PaymentServer/Processors/Stripe.hs | 28 +++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/PaymentServer/Processors/Stripe.hs b/src/PaymentServer/Processors/Stripe.hs index 5e78f3f..c1047de 100644 --- a/src/PaymentServer/Processors/Stripe.hs +++ b/src/PaymentServer/Processors/Stripe.hs @@ -18,14 +18,10 @@ import Control.Exception ( try , throwIO ) -import Data.ByteString - ( ByteString - ) import Data.Text ( Text , unpack ) -import qualified Data.Map as Map import Text.Read ( readMaybe ) @@ -41,8 +37,6 @@ import Data.Aeson import Servant ( Server , Handler - , err400 - , err500 , ServerError(ServerError, errHTTPCode, errBody, errHeaders, errReasonPhrase) , throwError ) @@ -51,22 +45,12 @@ import Servant.API , JSON , Post , (:>) - , (:<|>)((:<|>)) - ) -import Web.Stripe.Event - ( Event(Event, eventId, eventType, eventData) - , EventId(EventId) - , EventType(ChargeSucceededEvent) - , EventData(ChargeEvent) ) import Web.Stripe.Types ( Charge(Charge, chargeMetaData) , MetaData(MetaData) , Currency ) -import Web.Stripe.Error - ( StripeError(StripeError) - ) import Web.Stripe.Charge ( createCharge , Amount(Amount) @@ -79,6 +63,9 @@ import Web.Stripe ( stripe , (-&-) ) + +import qualified Prometheus as P + import PaymentServer.Persistence ( Voucher , VoucherDatabase(payForVoucher) @@ -126,10 +113,19 @@ instance FromJSON Charges where v .: "currency" parseJSON _ = mzero +chargeAttempts :: P.Counter +chargeAttempts + = P.unsafeRegister + $ P.counter + $ P.Info "charge_attempts" "The number of attempted charge requests received." + -- | call the stripe Charge API (with token, voucher in metadata, amount, currency etc -- and if the Charge is okay, then set the voucher as "paid" in the database. charge :: VoucherDatabase d => StripeConfig -> d -> Charges -> Handler Acknowledgement charge stripeConfig d (Charges token voucher amount currency) = do + + liftIO $ P.incCounter chargeAttempts + currency' <- getCurrency currency result <- liftIO (try (payForVoucher d voucher (completeStripeCharge currency'))) case result of -- GitLab