Skip to content

Commit

Permalink
NTR: too early debug message instead of warning (#932)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalij Mik <[email protected]>
  • Loading branch information
BlackScorp and Vitalij Mik authored Jan 28, 2025
1 parent f98de58 commit f2b01c3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added

- Returns for Shopware Commercial plugins are now transferred to Mollie when the return status is set to "Done" and can be canceled with the "Cancelled" status. Please note that refunds cannot be canceled after two hours.
- MB Way payment method is now available for Mollie Payments.
- Multibanco payment method is now available for Mollie Payments.
Expand All @@ -17,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- The minimum supported Shopware version is now 6.4.5.0.
- Added a new Monolog channel "mollie." You can now add custom handlers and assign them to the Mollie channel.
- When a webhook from mollie is sent too early to the shop, a debug message is logged instead of a warning.

### Fixed

Expand Down
13 changes: 13 additions & 0 deletions src/Controller/Api/Webhook/WebhookControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Kiener\MolliePayments\Components\Subscription\Exception\SubscriptionSkippedException;
use Kiener\MolliePayments\Components\Subscription\SubscriptionManager;
use Kiener\MolliePayments\Controller\Storefront\Webhook\NotificationFacade;
use Kiener\MolliePayments\Exception\WebhookIsTooEarlyException;
use Kiener\MolliePayments\Repository\OrderRepository;
use Kiener\MolliePayments\Repository\OrderTransactionRepository;
use Psr\Log\LoggerInterface;
Expand All @@ -13,6 +14,7 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class WebhookControllerBase extends AbstractController
{
Expand Down Expand Up @@ -74,6 +76,17 @@ public function webhookAction(string $swTransactionId, Request $request, Context
return new JsonResponse([
'success' => true
]);
} catch (WebhookIsTooEarlyException $exception) {
$this->logger->debug('Webhook too early', [
['message' => $exception->getMessage()]
]);
return new JsonResponse(
[
'success' => false,
'error' => $exception->getMessage()
],
Response::HTTP_TOO_EARLY
);
} catch (\Throwable $ex) {
$this->logger->error(
'Error in Mollie Webhook for Transaction ' . $swTransactionId,
Expand Down
1 change: 1 addition & 0 deletions src/Controller/Storefront/Webhook/NotificationFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function __construct(MollieGatewayInterface $gatewayMollie, OrderStatusCo
/**
* @param string $swTransactionId
* @param Context $context
* @throws WebhookIsTooEarlyException
* @throws CustomerCouldNotBeFoundException
* @return void
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Controller/Storefront/Webhook/WebhookControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Kiener\MolliePayments\Components\Subscription\Exception\SubscriptionSkippedException;
use Kiener\MolliePayments\Components\Subscription\SubscriptionManager;
use Kiener\MolliePayments\Controller\Storefront\AbstractStoreFrontController;
use Kiener\MolliePayments\Exception\WebhookIsTooEarlyException;
use Kiener\MolliePayments\Repository\OrderRepository;
use Kiener\MolliePayments\Repository\OrderTransactionRepository;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -70,6 +71,15 @@ public function onWebhookReceived(SalesChannelContext $context, string $swTransa
$this->notificationFacade->onNotify($swTransactionId, $context->getContext());

return new JsonResponse(['success' => true]);
} catch (WebhookIsTooEarlyException $exception) {
$this->logger->debug(
'Webhook too early',
[
'error' => $exception->getMessage()
]
);

return new JsonResponse(['success' => false, 'error' => $exception->getMessage()], $exception->getStatusCode());
} catch (ShopwareHttpException $exception) {
$this->logger->warning(
'Warning in Webhook for Transaction ' . $swTransactionId,
Expand Down

0 comments on commit f2b01c3

Please sign in to comment.