HMAC not static

This commit is contained in:
Juan Pablo Vial
2025-06-03 23:04:57 -04:00
parent 1c3052219c
commit c5188a1feb
3 changed files with 12 additions and 17 deletions

View File

@ -27,7 +27,7 @@ class Toku extends Ideal\Service
protected Subscription $subscription;
protected Invoice $invoice;
public function __construct(LoggerInterface $logger, protected Connection $connection)
public function __construct(LoggerInterface $logger, protected Connection $connection, protected HMAC $hmac)
{
parent::__construct($logger);
}
@ -446,21 +446,9 @@ class Toku extends Ideal\Service
return false;
}
foreach ($results as $secret) {
$this->logger->info('Toku webhook validated', [
'timestamp' => $timestamp,
'signature' => $signature,
'eventId' => $eventId,
'eventType' => $eventType,
'secret' => $secret,
]);
if (HMAC::validate($timestamp, $signature, $eventId, $secret)) {
return true;
}
}
/*if (array_any($results, fn($secret) => HMAC::validate($timestamp, $signature, $eventId, $secret))) {
if (array_any($results, fn($secret) => $this->hmac->validate($timestamp, $signature, $eventId, $secret))) {
return true;
}*/
}
} catch (Throwable $throwable) {
$this->logger->error($throwable);