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

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:

App/Handler/CustomSignatureValidator is not a valid signature validation class. A valid signature validator is a class that implements SpatieWebhookClientSignatureValidatorSignatureValidator

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;
        }
    }

I’ve also tried using
use SpatieWebhookClientSignatureValidatorSignatureValidator as SignatureValidator;

But i am also getting the same error.

If you could tell me what am i doing wrong i would really appreciate it.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think you’ve got one too many CustomSignatureValidator. Your namespace is AppHandlerCustomSignatureValidator, which means your class will be AppHandlerCustomSignatureValidatorCustomSignatureValidator.

I’m guessing the error isn’t because your class is not implementing the right interface, but that it can’t be found by the autoloader.

Try removing CustomSignatureValidator from your namespace, which will cause your class to become AppHandlerCustomSignatureValidator, which Laravel should be able to find.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x