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

Safe HaskellNone

Web.Stripe.Client

Synopsis

Documentation

data StripeConfig Source

Configuration for the StripeT monad transformer.

newtype SecretKey Source

A key used when authenticating to the Stripe API.

Constructors

SecretKey 

Fields

unSecretKey :: Text
 

Instances

data StripeVersion Source

Stripe Version Represents Stripe API Versions

Instances

data StripeResponseCode 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 

data StripeFailure 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

Eq StripeFailure 
Show StripeFailure 
Error StripeFailure

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

Monad m => MonadError StripeFailure (StripeT m) 

data StripeError Source

Describes a StripeFailure 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 (StripeErrorCode), 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

Eq StripeError 
Show StripeError 
FromJSON StripeError

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

data StripeErrorCode 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.

data StripeRequest 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.

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.

defaultConfig :: SecretKey -> StripeConfigSource

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

runStripeT :: MonadIO m => StripeConfig -> StripeT m a -> m (Either StripeFailure a)Source

Runs the StripeT monad transformer with a given StripeConfig. 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 :: StripeRequestSource

The basic StripeRequest 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, FromJSON a) => StripeRequest -> StripeT m (StripeResponseCode, 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 = StripeConfig "key" "CA file"

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

queryData :: (MonadIO m, FromJSON a) => StripeRequest -> StripeT m (StripeResponseCode, a)Source

same as query but pulls out the value inside a data field and returns that

query_ :: MonadIO m => StripeRequest -> 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, and PATCH which is defined by RFC 5789).

Constructors

GET 
POST 
HEAD 
PUT 
DELETE 
TRACE 
CONNECT 
OPTIONS 
PATCH