yesod-mangopay-1.11: Yesod library for MangoPay API access

Safe HaskellNone
LanguageHaskell98

Yesod.MangoPay

Description

typeclasses and helpers to access MangoPay from Yesod

Synopsis

Documentation

class YesodMangoPay site where Source

The YesodMangoPay class for foundation datatypes that support running MangoPayT actions.

Minimal complete definition

mpCredentials, mpHttpManager, mpToken

Methods

mpCredentials :: site -> Credentials Source

The credentials of your app.

mpHttpManager :: site -> Manager Source

HTTP manager used for contacting MangoPay (may be the same as the one used for yesod-auth).

mpUseSandbox :: site -> Bool Source

Use MangoPay's sandbox if True. The default is True for safety.

mpToken :: site -> IORef (Maybe MangoPayToken) Source

store the saved access token if we have one

runYesodMPT :: (MonadHandler m, MPUsableMonad m, HandlerSite m ~ site, YesodMangoPay site) => MangoPayT m a -> m a Source

Run a MangoPayT action inside a GHandler using your credentials.

runMPT :: (MPUsableMonad m, YesodMangoPay site) => site -> MangoPayT m a -> m a Source

Run a MangoPayT, given any instance of YesodMangoPay.

data MangoPayToken Source

the MangoPay access token, valid for a certain time only

Constructors

MangoPayToken 

Fields

mptToken :: AccessToken

opaque token

mptExpires :: UTCTime

expiration date

isTokenValid :: MonadResource m => MangoPayToken -> m Bool Source

is the given token still valid (True) or has it expired (False)?

getTokenIfValid :: (YesodMangoPay site, MonadResource m) => site -> m (Maybe MangoPayToken) Source

get the currently stored token if we have one and it's valid, or Nothing otherwise

getValidToken :: (YesodMangoPay site, MPUsableMonad m) => site -> m (Maybe AccessToken) Source

get a valid token, which could be one we had from before, or a new one

runYesodMPTToken :: (MonadHandler m, MPUsableMonad m, HandlerSite m ~ site, YesodMangoPay site) => (AccessToken -> MangoPayT m a) -> m a Source

Same as runYesodMPT: runs a MangoPayT computation, but tries to reuse the current token if valid.

runMPTToken :: (MPUsableMonad m, YesodMangoPay site) => site -> (AccessToken -> MangoPayT m a) -> m a Source

Same as runMPT: runs a MangoPayT computation, but tries to reuse the current token if valid.

registerAllMPCallbacks :: (MonadHandler m, MPUsableMonad m, HandlerSite m ~ site, YesodMangoPay site) => Route (HandlerSite m) -> m () Source

register callbacks for each event type on the same url mango pay does not let register two hooks for the same event, so we replace existing ones

registerAllMPCallbacksToURL :: (MPUsableMonad m, YesodMangoPay site) => site -> Text -> m [Hook] Source

register callbacks for each event type on the same url mango pay does not let register two hooks for the same event, so we replace existing ones

registerMPCallback :: (MonadHandler m, MPUsableMonad m, HandlerSite m ~ site, YesodMangoPay site) => Route (HandlerSite m) -> EventType -> Maybe Text -> m (AccessToken -> MangoPayT m Hook) Source

register a call back using the given route

parseMPNotification :: (MonadHandler m, HandlerSite m ~ site) => m Event Source

parse a event from a notification callback

catchMP :: forall m a. MonadBaseControl IO m => m a -> (MpException -> m a) -> m a Source

catches any exception that the MangoPay library may throw and deals with it in a error handler