| Conditions | 4 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 10 |
| 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) : |
||
|
|
|||
| 37 | config('gocardless.webhooks.webhook_endpoint_secret'); |
||
| 38 | |||
| 39 | if (empty($secret)) { |
||
| 40 | throw WebhookFailed::noSecretKeyProvided(); |
||
| 41 | } |
||
| 42 | |||
| 43 | try { |
||
| 44 | Webhook::parse($payload, $signature, $secret); |
||
| 45 | } catch (Exception $e) { |
||
| 46 | return false; |
||
| 47 | } |
||
| 48 | |||
| 49 | return true; |
||
| 50 | } |
||
| 52 | } |