spatie/laravel-stripe-webhooks
Laravel package to handle Stripe webhooks: verifies Stripe signatures, logs valid calls to the database, and dispatches configurable jobs or events per webhook type. Provides the plumbing for receiving and validating webhooks; you implement the business logic.
webhook_calls table mitigates duplicate event risks, a critical requirement for financial systems.webhook_calls table, which is a minor trade-off for reliability and auditability. Migration is straightforward via Artisan.verify_signature) in non-production environments could expose the system to replay attacks. Requires disciplined environment management.failed_jobs table monitoring).STRIPE_WEBHOOK_QUEUE) may need tuning (e.g., dedicated queue, batch processing).webhook_calls table is backed up and retained per compliance policies.stripe-mock or Laravel’s HTTP tests.ProcessStripeWebhookJob or WebhookProfile.webhook_calls table. No schema migrations for other databases.composer require spatie/laravel-stripe-webhooks
php artisan vendor:publish --provider="Spatie\StripeWebhooks\StripeWebhooksServiceProvider"
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
php artisan migrate
.env with STRIPE_WEBHOOK_SECRET (from Stripe Dashboard).stripe-webhooks.php:
charge.succeeded → HandleSuccessfulCharge).default_job if needed (e.g., for unhandled events).queue (e.g., stripe) and connection (e.g., redis).App\Http\Middleware\VerifyCsrfToken.Route::stripeWebhooks('/stripe/webhook');
payment_intent.succeeded, invoice.payment_failed).VerifyStripeWebhookSignature before business logic middleware.default_job to handle unregistered events gracefully.try-catch in jobs to log failures without crashing the webhook handler.stripe-webhooks.php for changes (e.g., new event types). Use environment variables for secrets to avoid hardcoding.failed_jobs table or tools like Horizon.stripe-webhooks channel).payment_intent.succeeded).webhook_calls table to audit events. Add indexes on payload->id and created_at for performance.ProcessStripeWebhookJob::dispatch(WebhookCall::find($id));
stripe) to isolate webhook processing from other jobs.webhook_calls by date if retention policies require archiving old events.How can I help you explore Laravel packages today?