Conditions | 4 |
Paths | 6 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | protected function isValid(string $signature, string $payload, string $configKey = null) : bool |
||
34 | { |
||
35 | $secret = ($configKey) ? |
||
36 | config('gocardless.webhooks.webhook_endpoint_secret_' . $configKey) : config('gocardless.webhooks.webhook_endpoint_secret'); |
||
|
|||
37 | |||
38 | if (empty($secret)) { |
||
39 | throw WebhookFailed::noSecretKeyProvided(); |
||
40 | } |
||
41 | |||
42 | try { |
||
43 | Webhook::parse($payload, $signature, $secret); |
||
44 | } catch (Exception $e) { |
||
45 | return false; |
||
46 | } |
||
47 | |||
48 | return true; |
||
49 | } |
||
51 | } |