summaryrefslogtreecommitdiff
path: root/src/Shop/Types.hs
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-02-27 19:56:09 +0100
committerFélix Sipma <felix.sipma@no-log.org>2018-02-27 19:56:09 +0100
commitae2cd91c3616a1dcd6147904116b4a502f4d544b (patch)
treebaf18ff502be325951711f75dd4f33a7481dd52e /src/Shop/Types.hs
parent1dade9829ff89d8b7613951847d6dbdf2bdab330 (diff)
add initial stripe support
Diffstat (limited to 'src/Shop/Types.hs')
-rw-r--r--src/Shop/Types.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Shop/Types.hs b/src/Shop/Types.hs
index 058317d..639c123 100644
--- a/src/Shop/Types.hs
+++ b/src/Shop/Types.hs
@@ -2,6 +2,7 @@
module Shop.Types
( Product(..)
, Article(..)
+ , TokenId(..)
, ChargeForm(..)
, ChargeResponse(..)
)
@@ -10,6 +11,7 @@ module Shop.Types
import Protolude hiding (Product(..))
import Data.Aeson (ToJSON(..), FromJSON(..), Value(..))
import Servant.API
+import Web.Stripe.Types (TokenId(..))
data ChargeResponse = ChargeResponse
@@ -45,12 +47,23 @@ data Article = Article
instance ToJSON Article
instance FromJSON Article
+instance FromHttpApiData TokenId where
+ parseUrlPiece = Right . TokenId . toS
+
+instance FromJSON TokenId where
+ parseJSON (String v) = return $ TokenId (toS v)
+ parseJSON _ = mzero
+
+instance ToJSON TokenId where
+ toJSON (TokenId tid) = String tid
+
data ChargeForm = ChargeForm
{ name :: Text
, email :: Text
, phone :: Text
, date :: Text
, articles :: [Article]
+ , tokenid :: TokenId
}
deriving (Show, Read, Generic, Eq)