Can't make a custom Signature validator class [Laravel 8 Spatie Webhook Client]

Asked
Active3 hr before
Viewed126 times

6 Answers

classsignaturevalidatorcustom
90%

Try removing CustomSignatureValidator from your namespace, which will cause your class to become App\Handler\CustomSignatureValidator, which Laravel should be able to find.,I think you've got one too many CustomSignatureValidator. Your namespace is App\Handler\CustomSignatureValidator, which means your class will be App\Handler\CustomSignatureValidator\CustomSignatureValidator.,App/Handler/CustomSignatureValidator is not a valid signature validation class. A valid signature validator is a class that implements Spatie\WebhookClient\SignatureValidator\SignatureValidator,I am a beginner and I'm trying to make a custom signature validator class and following the Spatie documentation I made the file CustomSignatureValidator.php which implements Spatie\WebhookClient\SignatureValidator\SignatureValidator but I'm getting the following error:

This is how it looks like:

 < ? php

 namespace App\ Handler\ CustomSignatureValidator;

 use Illuminate\ Http\ Request;
 use Spatie\ WebhookClient\ Exceptions\ WebhookFailed;
 use Spatie\ WebhookClient\ WebhookConfig;
 use Spatie\ WebhookClient\ SignatureValidator\ SignatureValidator;

 class CustomSignatureValidator implements SignatureValidator {
    public
    function isValid(Request $request, WebhookConfig $config): bool {
       return true;
    }
 }
load more v
88%

App/Handler/CustomSignatureValidator is not a valid signature validation class. A valid signature validator is a class that implements SpatieWebhookClientSignatureValidatorSignatureValidator,I am a beginner and I'm trying to make a custom signature validator class and following the Spatie documentation I made the file CustomSignatureValidator.php which implements SpatieWebhookClientSignatureValidatorSignatureValidator but I'm getting the following error:,Try removing CustomSignatureValidator from your namespace, which will cause your class to become AppHandlerCustomSignatureValidator, which Laravel should be able to find.,I've just started looking at spatie/laravel-analytics, a package for getting data out of Google Analytics API. I'm a bit lost right now though as documentation...

This is how it looks like:

 < ? php

 namespace AppHandlerCustomSignatureValidator;

 use IlluminateHttpRequest;
 use SpatieWebhookClientExceptionsWebhookFailed;
 use SpatieWebhookClientWebhookConfig;
 use SpatieWebhookClientSignatureValidatorSignatureValidator;

 class CustomSignatureValidator implements SignatureValidator {
    public
    function isValid(Request $request, WebhookConfig $config): bool {
       return true;
    }
 }
load more v
72%

App/Handler/CustomSignatureValidator is not a valid signature validation class. A valid signature validator is a class that implements SpatieWebhookClientSignatureValidatorSignatureValidator,I am a beginner and I’m trying to make a custom signature validator class and following the Spatie documentation I made the file CustomSignatureValidator.php which implements SpatieWebhookClientSignatureValidatorSignatureValidator but I’m getting the following error:, Laravel 8 and Vue Js – Update methode

This is how it looks like:

 < ? php

 namespace AppHandlerCustomSignatureValidator;

 use IlluminateHttpRequest;
 use SpatieWebhookClientExceptionsWebhookFailed;
 use SpatieWebhookClientWebhookConfig;
 use SpatieWebhookClientSignatureValidatorSignatureValidator;

 class CustomSignatureValidator implements SignatureValidator {
    public
    function isValid(Request $request, WebhookConfig $config): bool {
       return true;
    }
 }
load more v
65%

A signature validator is any class that implements Spatie\WebhookClient\SignatureValidator\SignatureValidator. Here's what that interface looks like.,After creating your own SignatureValidator you must register it in the signature_validator in the webhook-client config file.,A webhook profile is any class that implements \Spatie\WebhookClient\WebhookProfile\WebhookProfile. This is what that interface looks like:,A webhook response is any class that implements \Spatie\WebhookClient\WebhookResponse\RespondsToWebhook. This is what that interface looks like:

composer require spatie / laravel - webhook - client
load more v
75%

Ready to dig in? Let's go!,Let's take a look at the code to send a webhook again.,After the job has been dispatched, the controller will respond with a 200 status code. The webhook sending app now knows that the webhook request was well received.,If you need to send and/or receive webhooks in Laravel take a look at laravel-webhook-server and/or laravel-webhook-client packages. They are feature rich and robust. In the blog post above I've highlighted the most important bits, but the readmes of the package contain much more info.

laravel-webhook-server allows you to configure and send webhooks in a Laravel app easily. So you'll install this into the app that wants to notify other apps that something has happened. The package has support for signing calls, retrying calls, and backoff strategies. Before going further into that, let's first take a look at how you can send out webhook calls.

WebhookCall::create() -
   > url('https://other-app.com/webhooks') -
   > payload(['key' => 'value']) -
   > useSecret('sign-using-this-secret') -
   > dispatch();
load more v
40%

webhookUrl: the URL to where the request was sent,We don't recommend this, but if you don't want the web hook request to be signed call the doNotSign method.,If you want to customize the signing process, you can create your own custom signer. A signer is any class that implements Spatie\WebhookServer\Signer.,This is the contents of the file that will be published at config/webhook-server.php:

You can install the package via composer:

composer require spatie / laravel - webhook - server
load more v

Other "class-signature" queries related to "Can't make a custom Signature validator class [Laravel 8 Spatie Webhook Client]"