spatie/laravel-stripe-webhooks
Laravel package to handle Stripe webhooks: verifies Stripe signatures, stores valid webhook calls in the database, and dispatches configurable jobs or events per Stripe event type. You implement the business logic (payments, subscriptions, etc.).
shouldProcess) may introduce edge cases.webhook_calls table. Consider archiving or pruning strategies.failed_jobs table and adjust queue workers.STRIPE_WEBHOOK_SECRET and multi-secret configs managed (e.g., env vars, Vault)?WebhookFailed exception handler.Stripe\Event::constructFrom).webhook_calls table (MySQL/PostgreSQL recommended). Consider indexing payload->id for deduplication.charge.succeeded).payment_intent.succeeded, invoice.payment_succeeded) to the jobs config.composer.json for exact ranges).VerifyCsrfToken excludes the webhook route (handled by the package).QUEUE_CONNECTION=redis).php artisan vendor:publish) and migrations.php artisan migrate).routes/web.php:
Route::stripeWebhooks('stripe/webhook');
config/stripe-webhooks.php.StripeWebhookProfile for filtering).Http::fake()).config/stripe-webhooks.php. Use environment variables for secrets (e.g., STRIPE_WEBHOOK_SECRET).webhook_calls. Consider:
payload->id).WebhookFailed exceptions).failed_jobs table growth).webhook_calls table for payloads/exceptions.telescope or laravel-debugbar to trace job execution.webhook_calls table by date if volume exceeds millions/month.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid signature | Rejected webhook (no processing) | Monitor WebhookFailed exceptions; verify Stripe secret in config. |
| Queue overload | Delayed processing | Scale workers; implement circuit breakers for critical events. |
| Database connection issues | Lost webhook logs | Use queue retries; archive logs to S3/backup DB. |
| Stripe API changes | Broken payload parsing | Test with Stripe’s test mode; update package if needed. |
| Custom logic errors | Silent failures | Wrap job handlers in try-catch; log exceptions to webhook_calls.exception. |
| Duplicate events | Idempotent processing | Leverage package’s deduplication; add custom shouldProcess logic if needed. |
webhook_calls).webhook_calls).How can I help you explore Laravel packages today?