Issues (364)

app/Http/Middleware/VerifyStripeWebhook.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use Stripe\Exception\SignatureVerificationException;
8
use Stripe\WebhookSignature;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
11
12
class VerifyStripeWebhook
13
{
14
    /**
15
     * Handle an incoming request.
16
     *
17
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
18
     *
19
     * @throws \Symfony\Component\HttpKernal\Exception\AccessDeniedHttpException
20
     */
21
    public function handle(Request $request, Closure $next): Response
22
    {
23
        try {
24
            WebhookSignature::verifyHeader(
25
                $request->getContent(),
26
                $request->header('Stripe-Signature'),
0 ignored issues
show
It seems like $request->header('Stripe-Signature') can also be of type array; however, parameter $header of Stripe\WebhookSignature::verifyHeader() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
                /** @scrutinizer ignore-type */ $request->header('Stripe-Signature'),
Loading history...
27
                \Config::get('services.stripe.webhook'),
28
                null
29
            );
30
        } catch (SignatureVerificationException $exception) {
31
            throw new AccessDeniedHttpException($exception->getMessage(), $exception);
32
        }
33
34
        return $next($request);
35
    }
36
}
37