stripe-0.1: A Haskell implementation of the Stripe API.

Web.Stripe.Client

Synopsis

Documentation

data SConfig Source

Configuration for the StripeT monad transformer.

Constructors

SConfig 

Fields

key :: APIKey
 
caFile :: FilePath
 

newtype APIKey Source

A key used when authenticating to the Stripe API.

Constructors

APIKey 

Fields

unAPIKey :: String
 

Instances

data SResponseCode Source

This represents the possible successes that a connection to the Stripe API can encounter. For specificity, a success can be represented by other error codes, and so the same is true in this data type.

Please consult the official Stripe REST API documentation on error codes at https://stripe.com/docs/api#errors for more information.

Constructors

OK 
Unknown Int 

Instances

data SFailure Source

This represents the possible failures that a connection to the Stripe API can encounter.

Please consult the official Stripe REST API documentation on error codes at https://stripe.com/docs/api#errors for more information.

Instances

Show SFailure 
Error SFailure

Defines the behavior for more general error messages that can be thrown with noMsg and strMsg in combination with throwError.

Monad m => MonadError SFailure (StripeT m) 

data SError Source

Describes a SFailure in more detail, categorizing the error and providing additional information about it. At minimum, this is a message, and for CardError, this is a message, even more precise code (SErrorCode), and potentially a paramter that helps suggest where an error message should be displayed.

In case the appropriate error could not be determined from the specified type, UnkownError will be returned with the supplied type and message.

Please consult the official Stripe REST API documentation on error codes at https://stripe.com/docs/api#errors for more information.

Instances

Show SError 
JSON SError

Attempts to parse error information provided with each error by the Stripe API. In the parsing, the error is classified as a specific SError and any useful data, such as a message explaining the error, is extracted accordingly.

data SErrorCode Source

Attempts to describe a CardError in more detail, classifying in what specific way it failed.

Please consult the official Stripe REST API documentation on error codes at https://stripe.com/docs/api#errors for more information.

Instances

data SRequest Source

Represents a request to the Stripe API, providing the fields necessary to specify a Stripe resource. More generally, baseSReq will be desired as it provides sensible defaults that can be overriden as needed.

Constructors

SRequest 

Instances

type Stripe a = StripeT IO aSource

A convenience specialization of the StripeT monad transformer in which the underlying monad is IO.

newtype StripeT m a Source

Defines the monad transformer under which all Stripe REST API resource calls take place.

Constructors

StripeT (StateT SConfig (ErrorT SFailure m) a) 

defaultConfig :: APIKey -> SConfigSource

Provides a default SConfig. Essentially, this inserts the APIKey, but leaves other fields blank. This is especially relavent due to the current CA file check bug.

runStripeT :: MonadIO m => SConfig -> StripeT m a -> m (Either SFailure a)Source

Runs the StripeT monad transformer with a given SConfig. This will handle all of the authorization dance steps necessary to utilize the Stripe API.

Its use is demonstrated in other functions, such as query.

baseSReq :: SRequestSource

The basic SRequest environment upon which all other Stripe API requests will be built. Standard usage involves overriding one or more of the fields. E.g., for a request to "https:api.stripe.comv1coupons", one would have:

 baseSReq { sDestinaton = ["charges"] }

query :: (MonadIO m, JSON a) => SRequest -> StripeT m (SResponseCode, a)Source

Queries the Stripe API and attempts to parse the results into a data type that is an instance of JSON. This is primarily for internal use by other Stripe submodules, which supply the request values accordingly. However, it can also be used directly. E.g.,

 let conf = SConfig "key" "CA file"

 runStripeT conf $
    query baseSReq { sDestination = ["charges"] }

query_ :: MonadIO m => SRequest -> StripeT m ()Source

Acts just like query, but on success, throws away the response. Errors contacting the Stripe API will still be reported.

data StdMethod

HTTP standard method (as defined by RFC 2616).

Constructors

GET 
POST 
HEAD 
PUT 
DELETE 
TRACE 
CONNECT 
OPTIONS