PinStripe.WebhookHandler (PinStripe v0.4.0)

View Source

Spark DSL for defining webhook handlers.

This module provides a DSL for defining handlers for Stripe webhook events. It is primarily used internally by PinStripe.WebhookController.

Example

defmodule MyApp.StripeWebhookHandlers do
  use PinStripe.WebhookHandler

  handle "customer.created", fn event ->
    # Process customer.created event
    :ok
  end

  handle "charge.succeeded", MyApp.ChargeHandler
end

Handlers can be either:

  • Anonymous functions that take the event as an argument
  • Module names that implement a handle_event/1 function

Options

  • :extensions (list of module that adopts Spark.Dsl.Extension) - A list of DSL extensions to add to the Spark.Dsl

  • :otp_app (atom/0) - The otp_app to use for any application configurable options

  • :fragments (list of module/0) - Fragments to include in the Spark.Dsl. See the fragments guide for more.