mix pin_stripe.sync_webhook_handlers (PinStripe v0.4.0)
View SourceSync webhook handlers with Stripe's configured webhook endpoints
This task will:
- Fetch all webhook endpoints from your Stripe account using the Stripe CLI
- Extract all enabled events from those endpoints
- Compare them with handlers in your WebhookHandler module
- Generate handlers for any missing events
This is useful for keeping your local webhook handlers in sync with your Stripe webhook configuration, especially after adding new events in the Stripe Dashboard.
Example
mix pin_stripe.sync_webhook_handlers
Options
--api-keyor-k- The Stripe API key to use (prompts to use config key if not provided)--handler-typeor-t- Type of handler to generate: "function", "module", or "ask" (default: prompts user)--skip-confirmationor-y- Skip confirmation prompts and generate all missing handlers--create-handler-module- Module name to create if no WebhookHandler module exists
Prerequisites
This task requires the Stripe CLI to be installed and authenticated:
# Install Stripe CLI (macOS)
brew install stripe/stripe-cli/stripe
# Login to Stripe
stripe login
Handler Types
Function Handler (inline)
Generates inline function handlers in your WebhookHandler module:
handle "customer.created", fn event ->
# Handle customer.created event
:ok
endModule Handler
Generates separate modules with a handle_event/1 function:
# In your WebhookHandler module
handle "customer.created", MyApp.StripeWebhookHandlers.CustomerCreated
# Generated module
defmodule MyApp.StripeWebhookHandlers.CustomerCreated do
def handle_event(event) do
# Handle customer.created event
:ok
end
endAsk (interactive)
Prompts you for each event individually, allowing you to choose function or module handlers on a per-event basis.