| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public function handle($request, Closure $next) |
||
| 20 | { |
||
| 21 | // validate that callback is coming from Paystack |
||
| 22 | if ((! $request->isMethod('post')) || ! $request->header('HTTP_X_PAYSTACK_SIGNATURE', null)) { |
||
| 23 | throw new AccessDeniedHttpException("Invalid Request"); |
||
| 24 | } |
||
| 25 | |||
| 26 | $input = $request->getContent(); |
||
| 27 | $paystack_key = config('paystackwebhooks.secret', env('PAYSTACK_SECRET')); |
||
| 28 | if ($request->header('HTTP_X_PAYSTACK_SIGNATURE') !== hash_hmac('sha512', $input, $paystack_key)) { |
||
| 29 | throw new AccessDeniedHttpException("Access Denied"); |
||
| 30 | } |
||
| 31 | |||
| 32 | return $next($request); |
||
| 33 | } |
||
| 35 |