stripe 0.5.0.0 → 0.6.0
raw patch · 7 files changed
+59/−41 lines, 7 filesdep ~http-conduitdep ~time
Dependency ranges changed: http-conduit, time
Files
- README.mkd +5/−5
- src/Web/Stripe/Card.hs +33/−7
- src/Web/Stripe/Charge.hs +5/−5
- src/Web/Stripe/Connect.hs +0/−8
- src/Web/Stripe/Customer.hs +7/−7
- src/Web/Stripe/Plan.hs +6/−6
- stripe.cabal +3/−3
README.mkd view
@@ -21,15 +21,15 @@ ```haskell {-# LANGUAGE OverloadedStrings #-} -import Web.Stripe.Charge ( Charge(..), Amount(..), Count(..), Currency(..)- , Offset(..), getCharges- )-import Web.Stripe.Client ( APIKey(..), StripeConfig, defaultConfig, runStripeT )+import Web.Stripe.Charge (Amount (..), Charge (..), Count (..),+ Currency (..), Offset (..), getCharges)+import Web.Stripe.Client (SecretKey (..), StripeConfig, defaultConfig,+ runStripeT) -- The secret key below is used on the live Stripe API documentation. In -- practice, you should always store your secret key securely. conf :: StripeConfig-conf = defaultConfig $ APIKey "sk_test_mkGsLqEW6SLnZa487HYfJVLf"+conf = defaultConfig $ SecretKey "sk_test_mkGsLqEW6SLnZa487HYfJVLf" main :: IO () main = do
src/Web/Stripe/Card.hs view
@@ -3,6 +3,8 @@ module Web.Stripe.Card ( Card(..) , RequestCard(..)+ , CardChecks(..)+ , CardCheckResult(..) , rCardKV ) where @@ -16,11 +18,12 @@ -- | Represents a credit card in the Stripe system. data Card = Card- { cardType :: T.Text- , cardCountry :: Maybe T.Text- , cardLastFour :: T.Text- , cardExpMonth :: Int- , cardExpYear :: Int+ { cardType :: T.Text+ , cardCountry :: Maybe T.Text+ , cardLastFour :: T.Text+ , cardExpMonth :: Int+ , cardExpYear :: Int+ , cardChecks :: CardChecks } deriving Show -- | Represents a credit car (with full details) that is used as input to the@@ -33,11 +36,21 @@ , rCardFullName :: Maybe T.Text , rCardAddrLineOne :: Maybe T.Text , rCardAddrLineTwo :: Maybe T.Text+ , rCardCity :: Maybe T.Text , rCardAddrZip :: Maybe T.Text , rCardAddrState :: Maybe T.Text , rCardAddrCountry :: Maybe T.Text } deriving Show +data CardChecks = CardChecks+ { checkCVC :: CardCheckResult+ , checkAddrLineOne :: CardCheckResult+ , checkZip :: CardCheckResult+ } deriving Show++data CardCheckResult = NotProvided | NotChecked | Passed | Failed+ deriving (Show, Eq)+ -- | Turns a 'RequestCard' into a list of key-value pairs that can be submitted -- to the Stripe API in a query. rCardKV :: RequestCard -> [(B.ByteString, B.ByteString)]@@ -51,8 +64,9 @@ -- Optional md = [ ("card[cvc]", textToByteString <$> rCardCVC rc) , ("card[name]", textToByteString <$> rCardFullName rc)- , ("card[address_line_1]", textToByteString <$> rCardAddrLineOne rc)- , ("card[address_line_2]", textToByteString <$> rCardAddrLineTwo rc)+ , ("card[address_line1]", textToByteString <$> rCardAddrLineOne rc)+ , ("card[address_line2]", textToByteString <$> rCardAddrLineTwo rc)+ , ("card[address_city]", textToByteString <$> rCardCity rc) , ("card[address_zip]", textToByteString <$> rCardAddrZip rc) , ("card[address_state]", textToByteString <$> rCardAddrState rc) , ("card[address_country]", textToByteString <$> rCardAddrCountry rc)@@ -70,4 +84,16 @@ <*> v .: "last4" <*> v .: "exp_month" <*> v .: "exp_year"+ <*> (CardChecks+ <$> v .: "cvc_check"+ <*> v .: "address_line1_check"+ <*> v .: "address_zip_check"+ ) parseJSON _ = mzero++instance FromJSON CardCheckResult where+ parseJSON Null = return NotProvided+ parseJSON (String s)+ | s == "unchecked" = return NotChecked+ | s == "pass" = return Passed+ parseJSON _ = return Failed
src/Web/Stripe/Charge.hs view
@@ -167,11 +167,11 @@ -- | Attempts to parse JSON into a 'Charge'. instance FromJSON Charge where parseJSON (Object v) = Charge- <$> (ChargeId <$> v .: "id")- <*> (fromSeconds <$> v .: "created")- <*> ((Description <$>) <$> v .:? "description")- <*> (Currency <$> v .: "currency")- <*> (Amount <$> v .: "amount")+ <$> (ChargeId <$> v .: "id")+ <*> (fromSeconds <$> v .: "created")+ <*> (fmap Description <$> v .:? "description")+ <*> (Currency <$> v .: "currency")+ <*> (Amount <$> v .: "amount") <*> v .: "livemode" <*> v .: "paid" <*> v .: "refunded"
src/Web/Stripe/Connect.hs view
@@ -83,14 +83,6 @@ ] -refreshTokenQuery :: Maybe Scope -> RefreshToken -> Query-refreshTokenQuery mScope token =- [ ("grant_type", Just "refresh_token")- , ("scope", pack . show <$> mScope)- , ("refresh_token", Just token)- ]-- -- HTTP ------------------------------------------------------------------------ -- TODO getAccessToken should get the SecretKey from the StripeT monad. getAccessToken :: SecretKey -> AuthCode -> IO (Maybe StripeConnectTokens)
src/Web/Stripe/Customer.hs view
@@ -49,7 +49,7 @@ -- | Represents a customer in the Stripe system. data Customer = Customer { custId :: CustomerId- , custEmail :: Email+ , custEmail :: Maybe Email , custDescription :: Maybe Description , custLive :: Bool , custCreated :: UTCTime@@ -172,10 +172,10 @@ -- | Attempts to parse JSON into a 'Customer'. instance FromJSON Customer where parseJSON (Object o) = Customer- <$> (CustomerId <$> o .: "id")- <*> (Email <$> o .: "email")- <*> (fmap . fmap) Description (o .:? "description")- <*> o .: "livemode"- <*> (fromSeconds <$> o .: "created")- <*> o .:? "active_card"+ <$> (CustomerId <$> o .: "id")+ <*> (fmap Email <$> o .:? "email")+ <*> (fmap Description <$> o .:? "description")+ <*> o .: "livemode"+ <*> (fromSeconds <$> o .: "created")+ <*> o .:? "active_card" parseJSON _ = mzero
src/Web/Stripe/Plan.hs view
@@ -130,10 +130,10 @@ -- | Attempts to parse JSON into a 'Plan'. instance FromJSON Plan where parseJSON (Object o) = Plan- <$> (PlanId <$> o .: "id")- <*> (Amount <$> o .: "amount")- <*> (toPlanInterval <$> o .: "interval")- <*> o .: "name"- <*> (Currency <$> o .: "currency")- <*> ((PlanTrialDays <$>) <$> o .:? "trial_period_days")+ <$> (PlanId <$> o .: "id")+ <*> (Amount <$> o .: "amount")+ <*> (toPlanInterval <$> o .: "interval")+ <*> o .: "name"+ <*> (Currency <$> o .: "currency")+ <*> (fmap PlanTrialDays <$> o .:? "trial_period_days") parseJSON _ = mzero
stripe.cabal view
@@ -1,5 +1,5 @@ Name: stripe-Version: 0.5.0.0+Version: 0.6.0 Synopsis: A Haskell implementation of the Stripe API. Description: This is an implementation of the Stripe API as it is documented at https:\/\/stripe.com\/docs\/api@@ -36,8 +36,8 @@ , text >= 0.11.0 && < 0.12 , aeson >= 0.6.1 && < 0.7 , unordered-containers >= 0.1.4.6 && < 0.3- , time >= 1.0.0 && < 1.5- , http-conduit >= 2.0.0 && < 2.0.1+ , time >= 1.0 && < 1.5+ , http-conduit >= 2.0 && < 2.1 , http-types >= 0.6.11 && < 0.9 , bytestring >= 0.9 && < 0.11 , mtl >= 2.1 && < 2.2