packages feed

snaplet-stripe 0.1.0 → 0.2.0

raw patch · 2 files changed

+16/−15 lines, 2 filesdep ~heistdep ~snapdep ~stripe

Dependency ranges changed: heist, snap, stripe

Files

snaplet-stripe.cabal view
@@ -1,5 +1,5 @@ name:           snaplet-stripe-version:        0.1.0+version:        0.2.0 synopsis:       Stripe snaplet for the Snap Framework description:    This snaplet contains support for using the Stripe                 payment platform with a Snap Framework application.@@ -27,15 +27,15 @@   build-depends:     base         >= 4.4     && < 5,     bytestring   >= 0.9.1   && < 0.11,-    snap         >= 0.11    && < 0.14,-    heist        >= 0.11    && < 0.14,+    snap         >= 0.13    && < 0.14,+    heist        >= 0.13    && < 0.14,     text         >= 0.11    && < 0.12,     text-format  >= 0.3     && < 0.4,     configurator >= 0.2     && < 0.3,     transformers >= 0.3     && < 0.4,     mtl          >= 2       && < 3,     xmlhtml      >= 0.2     && < 0.3,-    stripe       >= 0.3     && < 0.4+    stripe       >= 0.8     && < 0.9     ghc-options: -Wall -fwarn-tabs -funbox-strict-fields
src/Snap/Snaplet/Stripe.hs view
@@ -30,7 +30,6 @@ import           Data.Maybe                 (fromMaybe, isNothing) import           Data.Monoid                (mempty) import           Data.Text                  (Text)-import           Data.Text.Encoding         (decodeUtf8) import           Data.Text.Format           (Format, Only (..), format) import qualified Data.Text.Lazy             as TL import           Heist                      (HeistConfig (..))@@ -47,8 +46,9 @@ import           Web.Stripe.Charge          (Amount (..), Charge, ChargeId,                                              Currency, chargeCustomerById,                                              chargeTokenById, getCharge)-import           Web.Stripe.Client          (APIKey (..), StripeConfig (..),-                                             StripeFailure, key, runStripeT)+import           Web.Stripe.Client          (SecretKey (..), StripeConfig (..),+                                             StripeFailure, StripeVersion (..),+                                             runStripeT, stripeSecretKey) import           Web.Stripe.Connect         (AccessToken, ClientId, Landing,                                              Scope, URL, authURL,                                              createCustomerToken)@@ -90,12 +90,13 @@   config <- getSnapletUserConfig    (stripeState, errors) <- runWriterT $ do-    secretKey <- logErr "Must specify Strip secret key" $ C.lookup config "secret_key"-    publicKey <- logErr "Must specify Strip public key" $ C.lookup config "public_key"-    clientId  <- logErr "Must specify Strip client ID"  $ C.lookup config "client_id"+    secretKey <- logErr "Must specify Strip secret key"  $ C.lookup config "secret_key"+    publicKey <- logErr "Must specify Strip public key"  $ C.lookup config "public_key"+    clientId  <- logErr "Must specify Strip client ID"   $ C.lookup config "client_id"+    version   <- Just . maybe V20110915d OtherVersion <$> liftIO (C.lookup config "version")     let caFilePath = Just "" -- This is unused by Stripe but vestigial in the Haskell library. -    return $ StripeState <$> (StripeConfig <$> (APIKey <$> secretKey) <*> caFilePath) <*> (PublicKey <$> publicKey) <*> clientId+    return $ StripeState <$> (StripeConfig <$> (SecretKey <$> secretKey) <*> caFilePath <*> version) <*> (PublicKey <$> publicKey) <*> clientId   return $ fromMaybe (error $ intercalate "\n" errors) stripeState  @@ -132,7 +133,7 @@                       -> Maybe Description -> AccessToken -> Maybe Amount                       -> m (Either StripeFailure Charge) chargeConnectCustomer cid am cu md k maf = withSC $ \sc -> do-  let sc' = sc { key = accessTokenToKey k }+  let sc' = sc { stripeSecretKey = accessTokenToKey k }   let ch = tokId <$> createCustomerToken cid >>=           (\tid -> chargeTokenById tid am cu md maf)   runStripeT sc' ch@@ -148,7 +149,7 @@ connectCharge :: (Functor m, HasStripe m, MonadIO m) => AccessToken -> ChargeId                  -> m (Either StripeFailure Charge) connectCharge k c = withSC $ \sc -> do-  let sc' = sc { key = accessTokenToKey k }+  let sc' = sc { stripeSecretKey = accessTokenToKey k }   runStripeT sc' (getCharge c)  @@ -181,8 +182,8 @@ fromAmount = (/ 100) . fromIntegral . unAmount  -accessTokenToKey :: AccessToken -> APIKey-accessTokenToKey = APIKey . decodeUtf8+accessTokenToKey :: AccessToken -> SecretKey+accessTokenToKey = SecretKey   -- Public Key Splice