Skip to content

Service Integrations

LaraWebhook supports multiple webhook providers out of the box.

Built-in Services

ServiceSignature HeaderAlgorithm
StripeStripe-SignatureHMAC-SHA256 with timestamp
GitHubX-Hub-Signature-256HMAC-SHA256
SlackX-Slack-SignatureHMAC-SHA256 with timestamp
ShopifyX-Shopify-Hmac-Sha256Base64 HMAC-SHA256

Quick Setup

1. Add Secret to .env

env
STRIPE_WEBHOOK_SECRET=whsec_xxx
GITHUB_WEBHOOK_SECRET=xxx
SLACK_WEBHOOK_SECRET=xxx
SHOPIFY_WEBHOOK_SECRET=xxx

2. Create Route with Middleware

php
Route::post('/stripe-webhook', [StripeController::class, 'handle'])
    ->middleware('validate-webhook:stripe');

Route::post('/github-webhook', [GithubController::class, 'handle'])
    ->middleware('validate-webhook:github');

Route::post('/slack-webhook', [SlackController::class, 'handle'])
    ->middleware('validate-webhook:slack');

Route::post('/shopify-webhook', [ShopifyController::class, 'handle'])
    ->middleware('validate-webhook:shopify');

3. Handle the Webhook

php
public function handle(Request $request): JsonResponse
{
    // Webhook is already validated by middleware
    $payload = json_decode($request->getContent(), true);
    
    // Process your webhook
    // ...
    
    return response()->json(['status' => 'success']);
}

Adding Custom Services

LaraWebhook uses the Strategy Pattern for extensibility. See Extending LaraWebhook to add support for any webhook provider.

Validation Flow

┌─────────────────┐     ┌──────────────────────┐     ┌─────────────────────┐
│                 │     │                      │     │                     │
│  Provider       │────▶│  LaraWebhook         │────▶│  Your Application   │
│  (Webhook)      │     │  - Validates sig     │     │  - Process event    │
│                 │     │  - Logs event        │     │  - Update database  │
└─────────────────┘     │  - Returns response  │     │                     │
                        └──────────────────────┘     └─────────────────────┘

                                  │ Invalid

                        ┌──────────────────────┐
                        │  Returns 403/400     │
                        │  Logs failure        │
                        └──────────────────────┘

Released under the MIT License.