From a11b60306dd2cc2fe306e52af6493855550f1c73 Mon Sep 17 00:00:00 2001 From: Florian Bender Date: Thu, 27 Jul 2023 13:30:36 +0200 Subject: [PATCH 1/4] NTR: Correct selection string for giftcard --- view/frontend/web/template/payment/giftcard.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/web/template/payment/giftcard.html b/view/frontend/web/template/payment/giftcard.html index c9103c960e7..f3f395a5086 100644 --- a/view/frontend/web/template/payment/giftcard.html +++ b/view/frontend/web/template/payment/giftcard.html @@ -20,7 +20,7 @@
- +

From 90ca4178e2d26fbb4fafa8ee12e1ad8a3775cc01 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 10 Aug 2023 11:21:44 +0200 Subject: [PATCH 2/4] Bugfix: Do not process locked order to prevent timeouts --- Controller/Checkout/Webhook.php | 25 +++++++++++++++---------- Service/OrderLockService.php | 14 +++++++++++++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Controller/Checkout/Webhook.php b/Controller/Checkout/Webhook.php index d18a67e2d7d..12237d60e82 100644 --- a/Controller/Checkout/Webhook.php +++ b/Controller/Checkout/Webhook.php @@ -16,6 +16,7 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Mollie\Payment\Helper\General as MollieHelper; use Mollie\Payment\Model\Mollie as MollieModel; +use Mollie\Payment\Service\OrderLockService; /** * Class Webhook @@ -50,24 +51,19 @@ class Webhook extends Action * @var EncryptorInterface */ private $encryptor; - /** - * Webhook constructor. - * - * @param Context $context - * @param Session $checkoutSession - * @param MollieModel $mollieModel - * @param MollieHelper $mollieHelper - * @param OrderRepositoryInterface $orderRepository - * @param EncryptorInterface $encryptor + * @var OrderLockService */ + private $orderLockService; + public function __construct( Context $context, Session $checkoutSession, MollieModel $mollieModel, MollieHelper $mollieHelper, OrderRepositoryInterface $orderRepository, - EncryptorInterface $encryptor + EncryptorInterface $encryptor, + OrderLockService $orderLockService ) { $this->checkoutSession = $checkoutSession; $this->resultFactory = $context->getResultFactory(); @@ -75,6 +71,7 @@ public function __construct( $this->mollieHelper = $mollieHelper; $this->orderRepository = $orderRepository; $this->encryptor = $encryptor; + $this->orderLockService = $orderLockService; parent::__construct($context); } @@ -99,6 +96,14 @@ public function execute() } foreach ($orders as $order) { + // If this returns true, it means that the order is just created but did go straight to "paid". + // That can happen for Apple Pay and Credit Card. In that case, Mollie immediately sends a webhook, + // but we are not ready to process it yet. + if ($this->orderLockService->isLocked($order)) { + $this->mollieHelper->addTolog('info', 'Order is locked, skipping webhook'); + continue; + } + $order->setMollieTransactionId($transactionId); $this->mollieModel->processTransactionForOrder($order, 'webhook'); } diff --git a/Service/OrderLockService.php b/Service/OrderLockService.php index 9325aa9eac7..a414273dc78 100644 --- a/Service/OrderLockService.php +++ b/Service/OrderLockService.php @@ -45,7 +45,7 @@ public function __construct( public function execute(OrderInterface $order, callable $callback) { - $key = 'mollie.order.' . $order->getEntityId(); + $key = $this->getKeyName($order); if ($this->lockService->checkIfIsLockedWithWait($key)) { throw new LocalizedException(__('Unable to get lock for %1', $key)); } @@ -85,4 +85,16 @@ public function execute(OrderInterface $order, callable $callback) return $result; } + + public function isLocked(OrderInterface $order): bool + { + $key = $this->getKeyName($order); + + return $this->lockService->isLocked($key); + } + + private function getKeyName(OrderInterface $order): string + { + return 'mollie.order.' . $order->getEntityId(); + } } From 63b34019a8e456eb6541388d361c7afedd70a575 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 17 Aug 2023 09:28:10 +0200 Subject: [PATCH 3/4] Catch terminals API exception --- Block/Form/Pointofsale.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Block/Form/Pointofsale.php b/Block/Form/Pointofsale.php index cd1c7ab69d6..f65a1649596 100644 --- a/Block/Form/Pointofsale.php +++ b/Block/Form/Pointofsale.php @@ -9,6 +9,7 @@ use Magento\Framework\View\Element\Template\Context; use Magento\Payment\Block\Form; use Mollie\Api\Resources\Terminal; +use Mollie\Payment\Logger\MollieLogger; use Mollie\Payment\Service\Mollie\MollieApiClient; /** @@ -26,15 +27,21 @@ class Pointofsale extends Form * @var MollieApiClient */ private $mollieApiClient; + /** + * @var MollieLogger + */ + private $logger; public function __construct( Context $context, MollieApiClient $mollieApiClient, + MollieLogger $logger, array $data = [] ) { parent::__construct($context, $data); $this->mollieApiClient = $mollieApiClient; + $this->logger = $logger; } /** @@ -47,14 +54,18 @@ public function __construct( * } * @throws \Magento\Framework\Exception\LocalizedException * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Mollie\Api\Exceptions\ApiException */ public function getTerminals(): array { $storeId = $this->_storeManager->getStore()->getId(); - $mollieApiClient = $this->mollieApiClient->loadByStore((int)$storeId); - $terminals = $mollieApiClient->terminals->page(); + try { + $mollieApiClient = $this->mollieApiClient->loadByStore((int)$storeId); + $terminals = $mollieApiClient->terminals->page(); + } catch (\Mollie\Api\Exceptions\ApiException $exception) { + $this->logger->addErrorLog('terminals', $exception->getMessage()); + return []; + } $output = []; /** @var Terminal $terminal */ From 9159a239521e4761d08d41c0d2d0716a061624cb Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 17 Aug 2023 09:28:52 +0200 Subject: [PATCH 4/4] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a660dee2754..c905cafbe81 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.30.0", + "version": "2.30.1", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 74e52e8e561..6176ed6d23e 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v2.30.0 + v2.30.1 0 0 test