PHP code example of snb4crazy / webhook-manager-laravel

1. Go to this page and download the library: Download snb4crazy/webhook-manager-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

snb4crazy / webhook-manager-laravel example snippets


use WebhookManager\Laravel\Facades\Webhook;

Webhook::send(
    url: 'https://receiver.example.com/hooks/orders',
    payload: [
        'event' => 'order.created',
        'order_id' => $order->id,
        'total' => $order->total,
    ],
    options: [
        'event' => 'order.created',
        'secret' => config('services.partner.webhook_secret'),
        'headers' => ['X-Webhook-Source' => config('app.name')],
        'max_attempts' => 5,
        'queue' => true, // set false to send synchronously
    ],
);

use Illuminate\Http\Request;
use WebhookManager\Laravel\Facades\Webhook;

public function __invoke(Request $request)
{
    $signature = (string) $request->header('X-Webhook-Signature');

    abort_unless(
        Webhook::verify($request->getContent(), $signature, config('services.partner.webhook_secret')),
        401,
        'Invalid webhook signature.'
    );

    // Process verified payload...
}

use WebhookManager\Laravel\Facades\Webhook;

Webhook::retry($deliveryId);
// or Webhook::retry($deliveryModel);
bash
php artisan vendor:publish --tag=webhook-manager-config
php artisan vendor:publish --tag=webhook-manager-migrations
php artisan migrate
bash
php artisan queue:work