spatie/laravel-webhook-client
Receive and process incoming webhooks in Laravel. Verify signatures, store webhook payloads, and handle them in queued jobs. Flexible configuration for multiple webhook endpoints and secure validation.
webhook_calls table provides auditability and replayability, critical for compliance (e.g., GDPR) or debugging. This aligns with Laravel’s Eloquent ORM and database-first approach.Route::webhooks()).ProcessWebhookJob throws uncaught exceptions, the package logs them to the WebhookCall model but doesn’t retry by default. TPMs must implement retry logic (e.g., Laravel Horizon) or dead-letter queues.store_headers: ['*']) could bloat the database. TPMs must balance audit needs with storage costs.SignatureValidator is mandatory.webhook_calls uniqueness constraints).ProcessWebhookJob.WebhookCall model integrates with Laravel’s ORM.Route::webhooks() simplifies endpoint registration.webhook_calls table (supports migrations).shouldProcess checks for event.type === 'payment.succeeded').202 Accepted for async processing).composer require spatie/laravel-webhook-client.php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider"..env with WEBHOOK_CLIENT_SECRET and queue driver.Route::webhooks('endpoint').VerifyCsrfToken).ProcessWebhookJob to handle business logic (e.g., trigger Laravel events, update models).namespace App\Jobs;
use Spatie\WebhookClient\Jobs\ProcessWebhookJob;
class HandleStripeWebhook extends ProcessWebhookJob {
public function handle() {
$payload = $this->webhookCall->payload;
// Process Stripe event (e.g., create invoice, log payment)
}
}
v1.x of the package (deprecated).firebase/php-jwt for JWT).WebhookCall failures).webhook_calls (configurable via delete_after_days).name: 'stripe').WEBHOOK_CLIENT_STRIPE_SECRET).webhook_calls are versioned. TPMs should:
WEBHOOK_CLIENT_SECRET and sender’s signature format.webhook_calls table for malformed data.webhook_calls table may need indexing (e.g., created_at, payload_hash) for large volumes.How can I help you explore Laravel packages today?