Skip to content
Snippets Groups Projects
Commit 860596c7 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

remove unused imports

parent 6f02c2c0
No related branches found
No related tags found
1 merge request!69Paid vouchers metrics
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment