Safe Haskell | None |
---|
- data StripeConfig = StripeConfig {}
- newtype SecretKey = SecretKey {
- unSecretKey :: Text
- data StripeVersion
- data StripeResponseCode
- data StripeFailure
- = BadRequest (Maybe StripeError)
- | Unauthorized (Maybe StripeError)
- | NotFound (Maybe StripeError)
- | PaymentRequired (Maybe StripeError)
- | InternalServerError (Maybe StripeError)
- | BadGateway (Maybe StripeError)
- | ServiceUnavailable (Maybe StripeError)
- | GatewayTimeout (Maybe StripeError)
- | HttpFailure (Maybe Text)
- | OtherFailure (Maybe Text)
- data StripeError
- data StripeErrorCode
- data StripeRequest = StripeRequest {
- sMethod :: StdMethod
- sDestination :: [Text]
- sData :: [(ByteString, ByteString)]
- sQString :: [(String, String)]
- type Stripe a = StripeT IO a
- newtype StripeT m a = StripeT (StateT StripeConfig (ErrorT StripeFailure m) a)
- defaultConfig :: SecretKey -> StripeConfig
- runStripeT :: MonadIO m => StripeConfig -> StripeT m a -> m (Either StripeFailure a)
- baseSReq :: StripeRequest
- query :: (MonadIO m, FromJSON a) => StripeRequest -> StripeT m (StripeResponseCode, a)
- queryData :: (MonadIO m, FromJSON a) => StripeRequest -> StripeT m (StripeResponseCode, a)
- query_ :: MonadIO m => StripeRequest -> StripeT m ()
- data StdMethod
Documentation
data StripeConfig Source
Configuration for the StripeT
monad transformer.
Show StripeConfig | |
Monad m => MonadState StripeConfig (StripeT m) |
A key used when authenticating to the Stripe API.
data StripeVersion Source
Stripe Version Represents Stripe API Versions
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.
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.
Eq StripeFailure | |
Show StripeFailure | |
Error StripeFailure | Defines the behavior for more general error messages that can be thrown
with |
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.
InvalidRequestError Text | |
APIError Text | |
CardError Text StripeErrorCode (Maybe Text) | |
UnknownError Text Text |
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 |
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.
InvalidNumber | |
IncorrectNumber | |
InvalidExpiryMonth | |
InvalidExpiryYear | |
InvalidCVC | |
ExpiredCard | |
InvalidAmount | |
IncorrectCVC | |
CardDeclined | |
Missing | |
DuplicateTransaction | |
ProcessingError | |
UnknownErrorCode Text | Could not be matched; text gives error name. |
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.
StripeRequest | |
|
type Stripe a = StripeT IO aSource
A convenience specialization of the StripeT
monad transformer in which
the underlying monad is IO.
Defines the monad transformer under which all Stripe REST API resource calls take place.
StripeT (StateT StripeConfig (ErrorT StripeFailure m) a) |
Monad m => MonadError StripeFailure (StripeT m) | |
Monad m => MonadState StripeConfig (StripeT m) | |
Monad m => Monad (StripeT m) | |
Functor m => Functor (StripeT m) | |
Monad m => MonadPlus (StripeT m) | |
MonadIO m => MonadIO (StripeT m) |
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