Giter Club home page Giter Club logo

hs-stripe's Introduction

This is an unofficial Haskell implementation of the Stripe API.

Note that this has worked in my tests, but I have not used it in production yet. Try it thoroughly and let me know if you find any bugs or have any improvements.

Installation

Installation is simple. If you have cabal installed, just run:

cabal install stripe

and you'll be on your way!

Example Usage

{-# LANGUAGE OverloadedStrings #-}

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 $ SecretKey "sk_test_mkGsLqEW6SLnZa487HYfJVLf"

main :: IO ()
main  = do
    amounts <- runStripeT conf $ do
        charges <- getCharges Nothing (Just $ Count 5) (Just $ Offset 1)
        return   $ map getAmt charges
    either err (putStrLn . show) amounts
    where
        getAmt c = (unAmount $ chargeAmount c, unCurrency $ chargeCurrency c)
        err _    = putStrLn "Uh-oh! It didn't work :-("

Which produces the output along the lines of: [(842,"usd"),(2048,"usd"),(1010,"usd"),(4096,"usd"),(4200,"usd")].

Limitations

  • This package currently does not implement Stripe invoices.

Help

First, consult the Haddock and Stripe API docs to be certain you're using the API correctly. It's a good idea to try another library first to see if it works there. If you think you might be misunderstanding the API, or having an issue with Stripe itself, it's best to contact them.

If all of that fails, or if you otherwise think it's an issue with this implementation of the API, please submit an issue here. Better yet, submit a pull request with a proposed solution!

Contributors

License

We like the MIT license. See LICENSE.

hs-stripe's People

Contributors

lukehoersten avatar dmjio avatar michaelschade avatar gregwebs avatar singpolyma avatar ocharles avatar tdox avatar 2piix avatar maxcan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.