stripe-scotty-1.1.0.4: Listen for Stripe webhook events with Scotty
Safe HaskellSafe-Inferred
LanguageHaskell2010

Stripe.Scotty

Description

For a typical webhook server implemented with Scotty, probably the only thing you need from this module is one of these two actions:

  • requireSig - If your live mode and test mode webhooks use separate URLs.
  • requireSig_eitherMode - If your live mode and test mode webhooks use the same URL.
Synopsis

Documentation

requireSig :: (MonadIO m, ScottyError e) => WebhookSecretKey -> ActionT e m ByteString Source #

Terminates request processing if the request does not contain a valid Stripe signature header.

This action returns the request body as a strict byte string; it has to fully evaluate the request body to do the signature check, so we might as well return this information to you for subsequent use.

requireSig_eitherMode :: (MonadIO m, ScottyError e) => BothModes (Maybe WebhookSecretKey) -> ActionT e m (Mode, Value) Source #

Terminates request processing if the request does not contain a valid Stripe signature header.

This action returns the mode and JSON request body; it has to do this much parsing to determine the mode so that we can know which secret key to use in the verification, so we might as well return this information to you for subsequent use.

hasValidSig :: (Monad m, ScottyError e) => WebhookSecretKey -> ByteString -> ActionT e m Bool Source #

Determines whether the request contains a valid Stripe signature header.