PHP code example of kbv-vcos / laravel-webhook-client
1. Go to this page and download the library: Download kbv-vcos/laravel-webhook-client 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/ */
kbv-vcos / laravel-webhook-client example snippets
return [
'configs' => [
[
/*
* This package supports multiple webhook receiving endpoints. If you only have
* one endpoint receiving webhooks, you can use 'default'.
*/
'name' => 'default',
/*
* We expect that every webhook call will be signed using a secret. This secret
* is used to verify that the payload has not been tampered with.
*/
'signing_secret' => env('WEBHOOK_CLIENT_SECRET'),
/*
* The name of the header containing the signature.
*/
'signature_header_name' => 'Signature',
/*
* This class will verify that the content of the signature header is valid.
*
* It should implement \Spatie\WebhookClient\SignatureValidator\SignatureValidator
*/
'signature_validator' => \Spatie\WebhookClient\SignatureValidator\DefaultSignatureValidator::class,
/*
* This class determines if the webhook call should be stored and processed.
*/
'webhook_profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class,
/*
* This class determines the response on a valid webhook call.
*/
'webhook_response' => \Spatie\WebhookClient\WebhookResponse\DefaultRespondsTo::class,
/*
* The classname of the model to be used to store call. The class should be equal
* or extend Spatie\WebhookClient\Models\WebhookCall.
*/
'webhook_model' => \Spatie\WebhookClient\Models\WebhookCall::class,
/*
* The class name of the job that will process the webhook request.
*
* This should be set to a class that extends \Spatie\WebhookClient\Jobs\ProcessWebhookJob.
*/
'process_webhook_job' => '',
],
],
use Illuminate\Http\Request;
use Spatie\WebhookClient\WebhookConfig;
interface SignatureValidator
{
public function isValid(Request $request, WebhookConfig $config): bool;
}
namespace Spatie\WebhookClient\WebhookProfile;
use Illuminate\Http\Request;
interface WebhookProfile
{
public function shouldProcess(Request $request): bool;
}
namespace App\Jobs;
use Spatie\WebhookClient\Jobs\ProcessWebhookJob as SpatieProcessWebhookJob;
class ProcessWebhookJob extends SpatieProcessWebhookJob
{
public function handle()
{
// $this->webhookCall // contains an instance of `WebhookCall`
// perform the work here
}
}
namespace Spatie\WebhookClient\WebhookResponse;
use Illuminate\Http\Request;
use Spatie\WebhookClient\WebhookConfig;
interface RespondsToWebhook
{
public function respondToValidWebhook(Request $request, WebhookConfig $config);
}