-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NTR: PISHPS-379: prevet to accept webhooks too early (#902)
Co-authored-by: Vitalij Mik <[email protected]>
- Loading branch information
1 parent
2ff7b44
commit fc55d06
Showing
3 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
use Shopware\Core\Framework\ShopwareHttpException; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class WebhookIsTooEarlyException extends ShopwareHttpException | ||
{ | ||
public const MOLLIE_PAYMENTS__WEBHOOK_TOO_EARLY = 'MOLLIE_PAYMENTS__WEBHOOK_TOO_EARLY'; | ||
public function __construct(string $oderNumber, \DateTimeInterface $now, \DateTimeInterface $updatedTime) | ||
{ | ||
$message = 'Webhook is too early for order: {{orderNumber}}. The last updateTime of the order is {{lastUpdateTime}}. It should be higher than: {{now}}'; | ||
$parameters =[ | ||
'orderNumber' => $oderNumber, | ||
'lastUpdateTime' => $updatedTime->format('Y-m-d H:i:s'), | ||
'now' => $now->format('Y-m-d H:i:s'), | ||
]; | ||
|
||
parent::__construct($message, $parameters); | ||
} | ||
public function getErrorCode(): string | ||
{ | ||
return self::MOLLIE_PAYMENTS__WEBHOOK_TOO_EARLY; | ||
} | ||
|
||
public function getStatusCode(): int | ||
{ | ||
return Response::HTTP_TOO_EARLY; | ||
} | ||
} |