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

Safe HaskellNone

Yesod.MangoPay

Description

typeclasses and helpers to access MangoPay from Yesod

Synopsis

Documentation

class Yesod site => YesodMangoPay site whereSource

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

Methods

mpCredentials :: site -> CredentialsSource

The credentials of your app.

mpHttpManager :: site -> ManagerSource

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

mpUseSandbox :: site -> BoolSource

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 aSource

Run a MangoPayT action inside a GHandler using your credentials.

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 BoolSource

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 aSource

same as runYesodMPT: 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

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, YesodMangoPay site) => m EventSource

parse a event from a notification callback

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

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