stripe 0.8.1 → 0.8.3
raw patch · 5 files changed
+41/−11 lines, 5 filesdep ~aesondep ~textPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: aeson, text
API changes (from Hackage documentation)
+ Web.Stripe.Card: cardId :: Card -> Text
+ Web.Stripe.Card: deleteCard :: MonadIO m => CustomerId -> CardId -> StripeT m Bool
+ Web.Stripe.Client: instance (Monad m, Functor m) => Alternative (StripeT m)
+ Web.Stripe.Client: instance (Monad m, Functor m) => Applicative (StripeT m)
+ Web.Stripe.Client: instance MonadTrans StripeT
+ Web.Stripe.Connect: scPublishableKey :: StripeConnectTokens -> PublishableKey
+ Web.Stripe.Connect: type PublishableKey = Text
+ Web.Stripe.Token: cardId :: Card -> Text
+ Web.Stripe.Utils: CardId :: Text -> CardId
+ Web.Stripe.Utils: data CardId
+ Web.Stripe.Utils: instance Eq CardId
+ Web.Stripe.Utils: instance Show CardId
+ Web.Stripe.Utils: unCardId :: CardId -> Text
- Web.Stripe.Card: Card :: Text -> Maybe Text -> Text -> Int -> Int -> Text -> CardChecks -> Card
+ Web.Stripe.Card: Card :: Text -> Text -> Maybe Text -> Text -> Int -> Int -> Text -> CardChecks -> Card
- Web.Stripe.Connect: StripeConnectTokens :: AccessToken -> RefreshToken -> UserId -> StripeConnectTokens
+ Web.Stripe.Connect: StripeConnectTokens :: AccessToken -> RefreshToken -> UserId -> PublishableKey -> StripeConnectTokens
- Web.Stripe.Token: Card :: Text -> Maybe Text -> Text -> Int -> Int -> Text -> CardChecks -> Card
+ Web.Stripe.Token: Card :: Text -> Text -> Maybe Text -> Text -> Int -> Int -> Text -> CardChecks -> Card
Files
- src/Web/Stripe/Card.hs +21/−4
- src/Web/Stripe/Client.hs +7/−1
- src/Web/Stripe/Connect.hs +7/−3
- src/Web/Stripe/Utils.hs +3/−0
- stripe.cabal +3/−3
src/Web/Stripe/Card.hs view
@@ -6,19 +6,24 @@ , CardChecks(..) , CardCheckResult(..) , rCardKV+ , deleteCard ) where import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero)+import Control.Monad (mzero, liftM)+import Control.Monad.Error (MonadIO) import Data.Aeson (FromJSON (..), Value (..), (.:), (.:?)) import qualified Data.ByteString as B import qualified Data.Text as T+import Data.Text (Text) import Web.Stripe.Utils (optionalArgs, showByteString,- textToByteString)+ textToByteString, CustomerId(..), CardId(..))+import Web.Stripe.Client -- | Represents a credit card in the Stripe system. data Card = Card- { cardType :: T.Text+ { cardId :: T.Text+ , cardType :: T.Text , cardCountry :: Maybe T.Text , cardLastFour :: T.Text , cardExpMonth :: Int@@ -80,7 +85,8 @@ -- | Attempts to parse JSON into a credit 'Card'. instance FromJSON Card where parseJSON (Object v) = Card- <$> v .: "type"+ <$> v .: "id"+ <*> v .: "type" <*> v .:? "country" <*> v .: "last4" <*> v .: "exp_month"@@ -99,3 +105,14 @@ | s == "unchecked" = return NotChecked | s == "pass" = return Passed parseJSON _ = return Failed++delCardReq :: Text -> Text -> StripeRequest+delCardReq custid cardid = + baseSReq { sDestination = "customers":custid:"cards":cardid:[] }++deleteCard :: MonadIO m => CustomerId -> CardId -> StripeT m Bool+deleteCard (CustomerId cid) (CardId cardid) =+ snd `liftM` query (delCardReq cid cardid) { sMethod = DELETE, sData = [] }+++
src/Web/Stripe/Client.hs view
@@ -25,13 +25,14 @@ , StdMethod(..) ) where +import Control.Applicative import Control.Arrow ((***)) import Control.Exception as EX import Control.Monad (MonadPlus, join, liftM, mzero) import Control.Monad.Error (Error, ErrorT, MonadError, MonadIO, noMsg, runErrorT, strMsg, throwError) import Control.Monad.State (MonadState, StateT, get, runStateT)-import Control.Monad.Trans (liftIO)+import Control.Monad.Trans (MonadTrans, lift, liftIO) import Data.Aeson (FromJSON (..), Value (..), decode', eitherDecode', (.:), (.:?)) import Data.Aeson.Types (parseMaybe)@@ -159,7 +160,12 @@ } deriving ( Functor, Monad, MonadIO, MonadPlus , MonadError StripeFailure , MonadState StripeConfig+ , Alternative+ , Applicative )++instance MonadTrans StripeT where+ lift = StripeT . lift . lift -- | Runs the 'StripeT' monad transformer with a given 'StripeConfig'. This will -- handle all of the authorization dance steps necessary to utilize the
src/Web/Stripe/Connect.hs view
@@ -12,6 +12,7 @@ , Landing (..) , AuthCode , AccessToken+ , PublishableKey , RefreshToken , UserId , ClientId@@ -46,15 +47,17 @@ type UserId = Text type ClientId = ByteString type AuthCode = ByteString+type PublishableKey = Text newtype StripeConnectException = StripeConnectException String deriving (Show, Eq, Typeable) data Scope = ReadOnly | ReadWrite deriving Eq data Landing = Login | Register deriving Eq data StripeConnectTokens = StripeConnectTokens- { scAccessToken :: AccessToken- , scRefreshToken :: RefreshToken- , scUserId :: UserId+ { scAccessToken :: AccessToken+ , scRefreshToken :: RefreshToken+ , scUserId :: UserId+ , scPublishableKey :: PublishableKey } deriving Show @@ -132,6 +135,7 @@ <$> o .: "access_token" <*> o .: "refresh_token" <*> o .: "stripe_user_id"+ <*> o .: "stripe_publishable_key" parseJSON _ = mzero
src/Web/Stripe/Utils.hs view
@@ -1,6 +1,7 @@ module Web.Stripe.Utils ( -- common types CustomerId(..)+ , CardId(..) , SubscriptionId(..) , Amount(..) , Count(..)@@ -46,6 +47,8 @@ -- -- | Represents a 'Customer'\'s ID in the Stripe system. newtype CustomerId = CustomerId { unCustomerId :: T.Text } deriving (Show, Eq)++data CardId = CardId { unCardId :: T.Text } deriving (Show, Eq) newtype SubscriptionId = SubscriptionId { unSubscriptionId :: T.Text } deriving (Show, Eq)
stripe.cabal view
@@ -1,5 +1,5 @@ Name: stripe-Version: 0.8.1+Version: 0.8.3 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@@ -35,8 +35,8 @@ , Web.Stripe.Token , Web.Stripe.Utils Build-depends: base >= 3 && < 5- , text >= 0.11.0 && < 1.2- , aeson >= 0.6.1 && < 0.8+ , text >= 0.11.0 && < 1.3+ , aeson >= 0.6.1 && < 0.9 , unordered-containers >= 0.1.4.6 && < 0.3 , time >= 1.0 && < 1.5 , http-conduit >= 2.0 && < 2.2