Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: too early debug message instead of warning #932

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading