Skip to content
Snippets Groups Projects
Commit ded42e07 authored by Ramakrishnan Muthukrishnan's avatar Ramakrishnan Muthukrishnan
Browse files

add a commandline parameter to take in the stripe API key

parent 7d58f8a1
No related branches found
No related tags found
1 merge request!30Expose a browser facing API for charge
......@@ -11,6 +11,8 @@ import Text.Printf
)
import Data.Maybe
( maybeToList
import Data.ByteString
( ByteString
)
import Data.Text
( Text
......@@ -90,6 +92,7 @@ data ServerConfig = ServerConfig
, database :: Database
, databasePath :: Maybe Text
, endpoint :: Endpoint
, stripeKey :: ByteString
}
deriving (Show, Eq)
......@@ -159,7 +162,9 @@ sample = ServerConfig
<> help "Path to on-disk database (sqlite3 only)"
<> showDefault ) )
<*> (http <|> https)
<*> option str
( long "stripe-key"
<> help "Stripe API key" )
opts :: ParserInfo ServerConfig
opts = info (sample <**> helper)
......@@ -221,6 +226,8 @@ getApp config =
exitFailure
Right getDB -> do
db <- getDB
let app = paymentServerApp issuer db
let port = 8081
let key = stripeKey config
let app = paymentServerApp key issuer db
logger <- mkRequestLogger (def { outputFormat = Detailed True})
return $ logger app
......@@ -8,6 +8,9 @@ module PaymentServer.Server
( paymentServerApp
) where
import Data.ByteString
( ByteString
)
import Servant
( Proxy(Proxy)
, Server
......@@ -37,9 +40,9 @@ type PaymentServerAPI
:<|> "v1" :> "redeem" :> RedemptionAPI
-- | Create a server which uses the given database.
paymentServer :: VoucherDatabase d => Issuer -> d -> Server PaymentServerAPI
paymentServer issuer database =
stripeServer database "test"
paymentServer :: VoucherDatabase d => ByteString -> Issuer -> d -> Server PaymentServerAPI
paymentServer key issuer database =
stripeServer database key
:<|> redemptionServer issuer database
paymentServerAPI :: Proxy PaymentServerAPI
......@@ -47,5 +50,5 @@ paymentServerAPI = Proxy
-- | Create a Servant Application which serves the payment server API using
-- the given database.
paymentServerApp :: VoucherDatabase d => Issuer -> d -> Application
paymentServerApp issuer = serve paymentServerAPI . paymentServer issuer
paymentServerApp :: VoucherDatabase d => ByteString -> Issuer -> d -> Application
paymentServerApp key issuer = serve paymentServerAPI . paymentServer key issuer
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment