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

Release/2.43.0 #859

Merged
merged 26 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0bc9cf0
Feature: Allow POS access for guests #823
michielgerritsen Dec 17, 2024
9d71e61
Improvement: Improved message when transaction fails
michielgerritsen Dec 30, 2024
321b1a9
Improvement: Add checks for Hyvä to the self tests
michielgerritsen Dec 30, 2024
ec8d37b
Bugfix: Check if the shipping address isset #841
michielgerritsen Jan 6, 2025
0fc0d49
Improvement: Do not log validation error #839
michielgerritsen Jan 6, 2025
7ad2224
Feature: New method MB Way
michielgerritsen Jan 2, 2025
a8128e4
Feature: New method Multibanco
michielgerritsen Jan 13, 2025
2e83f11
Improvement: Add retry mechanism for Cypress to handle async webhooks
michielgerritsen Jan 13, 2025
75c1795
Bugfix: Prevent race conditions when saving shipment trackings
michielgerritsen Jan 27, 2025
45c1b77
Merge branch 'feature/allow-pos-for-not-loggedin-groups' into release…
michielgerritsen Jan 27, 2025
4854b30
Merge branch 'feature/improved-error-message' into release-week-04
michielgerritsen Jan 27, 2025
b63caa5
Merge branch 'improvement/add-hyva-selftest-checks' into release-week-04
michielgerritsen Jan 27, 2025
3b36418
Merge branch 'feature/mbway' into release-week-04
michielgerritsen Jan 27, 2025
98c3f7e
Merge branch 'bugfix/check-if-shipping-exists' into release-week-04
michielgerritsen Jan 27, 2025
cbcf7db
Merge branch 'improvement/do-not-log-validation-error' into release-w…
michielgerritsen Jan 27, 2025
ce317e4
Merge branch 'improvement/add-retry-for-cypress' into release-week-04
michielgerritsen Jan 27, 2025
40a8c3d
Merge branch 'bugfix/prevent-race-condition-when-saving-shipment-trac…
michielgerritsen Jan 27, 2025
c820839
Merge branch 'feature/new-method-multibanco' into release-week-04
michielgerritsen Jan 27, 2025
ae20083
Improvement: Move billingEmail to billingAddress.email
michielgerritsen Jan 27, 2025
59ab623
Merge branch 'improvement/billingaddress-email' into release-week-04
michielgerritsen Jan 27, 2025
dd88523
Improvement: Add checks for Hyvä to the self tests
michielgerritsen Dec 30, 2024
06b702a
Merge branch 'improvement/add-hyva-selftest-checks' into release-week-04
michielgerritsen Jan 27, 2025
4426ce7
Typo
michielgerritsen Jan 30, 2025
08b7c33
Merge branch 'bugfix/prevent-race-condition-when-saving-shipment-trac…
michielgerritsen Jan 30, 2025
624cf4a
Update Cypress container
michielgerritsen Jan 30, 2025
6bc89d5
Version bump
Marvin-Magmodules Jan 30, 2025
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 .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Start the Magento container
run: |
openssl req -x509 -newkey rsa:4096 -keyout .github/workflows/templates/nginx-proxy/magento.test.key -out .github/workflows/templates/nginx-proxy/magento.test.crt -days 365 -nodes -subj "/CN=magento.test" && \
docker compose -f .github/workflows/templates/docker-compose.yml up -d
docker compose -f .github/workflows/templates/docker-compose.yml up -d --quiet-pull
# Get the URL from ngrok
docker compose -f .github/workflows/templates/docker-compose.yml logs ngrok
MAGENTO_URL=$(docker exec magento-project-community-edition /bin/bash -c "curl -s ngrok:4040/api/tunnels |jq -r \".tunnels[0].public_url\"")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/templates/e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cypress/included:13.6.2
FROM cypress/included:14.0.1

WORKDIR /e2e

Expand Down
40 changes: 9 additions & 31 deletions Controller/Checkout/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
namespace Mollie\Payment\Controller\Checkout;

use Magento\Framework\App\ResponseInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Sales\Api\OrderRepositoryInterface;
use Mollie\Payment\Model\Mollie as MollieModel;
Expand All @@ -18,6 +16,7 @@
use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Session;
use Mollie\Payment\Service\Mollie\GetMollieStatusResult;
use Mollie\Payment\Service\Mollie\Order\AddResultMessage;
use Mollie\Payment\Service\Mollie\Order\SuccessPageRedirect;
use Mollie\Payment\Service\Mollie\ProcessTransaction;
use Mollie\Payment\Service\Mollie\ValidateProcessRequest;
Expand Down Expand Up @@ -53,11 +52,6 @@ class Process extends Action
*/
private $orderRepository;

/**
* @var ManagerInterface
*/
private $eventManager;

/**
* @var RedirectOnError
*/
Expand All @@ -74,6 +68,10 @@ class Process extends Action
* @var SuccessPageRedirect
*/
private $successPageRedirect;
/**
* @var AddResultMessage
*/
private $addResultMessage;

public function __construct(
Context $context,
Expand All @@ -83,21 +81,21 @@ public function __construct(
MollieHelper $mollieHelper,
OrderRepositoryInterface $orderRepository,
RedirectOnError $redirectOnError,
ManagerInterface $eventManager,
ValidateProcessRequest $validateProcessRequest,
ProcessTransaction $processTransaction,
SuccessPageRedirect $successPageRedirect
SuccessPageRedirect $successPageRedirect,
AddResultMessage $addResultMessage
) {
$this->checkoutSession = $checkoutSession;
$this->paymentHelper = $paymentHelper;
$this->mollieModel = $mollieModel;
$this->mollieHelper = $mollieHelper;
$this->orderRepository = $orderRepository;
$this->redirectOnError = $redirectOnError;
$this->eventManager = $eventManager;
$this->validateProcessRequest = $validateProcessRequest;
$this->processTransaction = $processTransaction;
$this->successPageRedirect = $successPageRedirect;
$this->addResultMessage = $addResultMessage;

parent::__construct($context);
}
Expand Down Expand Up @@ -144,31 +142,11 @@ protected function handleNonSuccessResult(GetMollieStatusResult $result, array $
{
$this->checkIfLastRealOrder($orderIds);
$this->checkoutSession->restoreQuote();
$this->addResultMessage($result);
$this->addResultMessage->execute($result);

return $this->_redirect($this->redirectOnError->getUrl());
}

protected function addResultMessage(GetMollieStatusResult $result)
{
if ($result->getStatus() == 'canceled') {
$this->messageManager->addNoticeMessage(__('Payment canceled, please try again.'));
return;
}

if ($result->getStatus() == 'failed' && $result->getMethod()) {
$this->messageManager->addErrorMessage(
__(
'Payment of type %1 has been rejected. Decision is based on order and outcome of risk assessment.',
$result->getMethod()
)
);
return;
}

$this->messageManager->addErrorMessage(__('Transaction failed. Please verify your billing information and payment method, and try again.'));
}

/**
* @param array $orderIds
*/
Expand Down
3 changes: 3 additions & 0 deletions Model/Adminhtml/Source/CustomerGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function toOptionArray(): array
{
$groups = $this->groupManagement->getLoggedInGroups();

$notLoggedInGroup = $this->groupManagement->getNotLoggedInGroup();
array_unshift($groups, $notLoggedInGroup);

$output = [];
foreach ($groups as $group) {
$output[] = [
Expand Down
4 changes: 2 additions & 2 deletions Model/Client/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ public function startTransaction(OrderInterface $order, $mollieApi)
}

if ($method == 'banktransfer') {
$paymentData['billingEmail'] = $order->getCustomerEmail();
$paymentData['billingAddress']['email'] = $order->getCustomerEmail();
$paymentData['dueDate'] = $this->mollieHelper->getBanktransferDueDate($storeId);
}

if ($method == 'przelewy24') {
$paymentData['billingEmail'] = $order->getCustomerEmail();
$paymentData['billingAddress']['email'] = $order->getCustomerEmail();
}

$paymentData = $this->buildTransaction->execute($order, static::CHECKOUT_TYPE, $paymentData);
Expand Down
17 changes: 17 additions & 0 deletions Model/Methods/MbWay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Model\Methods;

class MbWay extends \Mollie\Payment\Model\Mollie
{
/**
* Payment method code
*
* @var string
*/
const CODE = 'mollie_methods_mbway';
}
17 changes: 17 additions & 0 deletions Model/Methods/Multibanco.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Model\Methods;

class Multibanco extends \Mollie\Payment\Model\Mollie
{
/**
* Payment method code
*
* @var string
*/
const CODE = 'mollie_methods_multibanco';
}
3 changes: 3 additions & 0 deletions Model/Methods/Reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Mollie\Payment\Model\Client\Payments as PaymentsApi;
use Mollie\Payment\Model\Mollie;
use Mollie\Payment\Service\Mollie\GetApiMethod;
use Mollie\Payment\Service\Mollie\LogException;
use Mollie\Payment\Service\OrderLockService;
use Mollie\Payment\Service\Mollie\MollieApiClient;
use Mollie\Payment\Service\Mollie\Timeout;
Expand Down Expand Up @@ -72,6 +73,7 @@ public function __construct(
MollieApiClient $mollieApiClient,
TransactionToOrderRepositoryInterface $transactionToOrderRepository,
GetApiMethod $getApiMethod,
LogException $logException,
RequestInterface $request,
$formBlockType,
$infoBlockType,
Expand Down Expand Up @@ -100,6 +102,7 @@ public function __construct(
$mollieApiClient,
$transactionToOrderRepository,
$getApiMethod,
$logException,
$formBlockType,
$infoBlockType,
$commandPool,
Expand Down
3 changes: 3 additions & 0 deletions Model/Methods/Voucher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Mollie\Payment\Model\Client\Payments as PaymentsApi;
use Mollie\Payment\Model\Mollie;
use Mollie\Payment\Service\Mollie\GetApiMethod;
use Mollie\Payment\Service\Mollie\LogException;
use Mollie\Payment\Service\OrderLockService;
use Mollie\Payment\Service\Mollie\MollieApiClient;
use Mollie\Payment\Service\Mollie\Timeout;
Expand Down Expand Up @@ -68,6 +69,7 @@ public function __construct(
MollieApiClient $mollieApiClient,
TransactionToOrderRepositoryInterface $transactionToOrderRepository,
GetApiMethod $getApiMethod,
LogException $logException,
$formBlockType,
$infoBlockType,
QuoteHasMealVoucherProducts $quoteHasMealVoucherProducts,
Expand Down Expand Up @@ -96,6 +98,7 @@ public function __construct(
$mollieApiClient,
$transactionToOrderRepository,
$getApiMethod,
$logException,
$formBlockType,
$infoBlockType,
$commandPool,
Expand Down
9 changes: 8 additions & 1 deletion Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Mollie\Payment\Model\Client\Payments as PaymentsApi;
use Mollie\Payment\Model\Client\ProcessTransactionResponse;
use Mollie\Payment\Service\Mollie\GetApiMethod;
use Mollie\Payment\Service\Mollie\LogException;
use Mollie\Payment\Service\OrderLockService;
use Mollie\Payment\Service\Mollie\Timeout;
use Mollie\Payment\Service\Mollie\Wrapper\MollieApiClientFallbackWrapper;
Expand Down Expand Up @@ -121,6 +122,10 @@ class Mollie extends Adapter
* @var GetApiMethod
*/
private $getApiMethod;
/**
* @var LogException
*/
private $logException;

public function __construct(
ManagerInterface $eventManager,
Expand All @@ -142,6 +147,7 @@ public function __construct(
\Mollie\Payment\Service\Mollie\MollieApiClient $mollieApiClient,
TransactionToOrderRepositoryInterface $transactionToOrderRepository,
GetApiMethod $getApiMethod,
LogException $logException,
$formBlockType,
$infoBlockType,
CommandPoolInterface $commandPool = null,
Expand Down Expand Up @@ -179,6 +185,7 @@ public function __construct(
$this->mollieApiClient = $mollieApiClient;
$this->transactionToOrderRepository = $transactionToOrderRepository;
$this->getApiMethod = $getApiMethod;
$this->logException = $logException;
}

public function getCode()
Expand Down Expand Up @@ -280,7 +287,7 @@ private function startTransactionUsingTheOrdersApi(OrderInterface $order, Mollie
return $this->ordersApi->startTransaction($order, $mollieApi);
});
} catch (\Exception $exception) {
$this->mollieHelper->addTolog('error', $exception->getMessage());
$this->logException->execute($exception);
}

$methodCode = $this->mollieHelper->getMethodCode($order);
Expand Down
22 changes: 15 additions & 7 deletions Observer/LockUnlockOrder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Observer;

Expand All @@ -7,7 +11,6 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\ShipmentInterface;
use Mollie\Payment\Config;
use Mollie\Payment\Service\LockService;

class LockUnlockOrder implements ObserverInterface
Expand All @@ -18,16 +21,14 @@ class LockUnlockOrder implements ObserverInterface
private $lockService;

/**
* @var Config
* @var string
*/
private $config;
private $reason = '';

public function __construct(
Config $config,
LockService $lockService
) {
$this->lockService = $lockService;
$this->config = $config;
}

public function execute(Observer $observer)
Expand All @@ -41,7 +42,7 @@ public function execute(Observer $observer)
throw new LocalizedException(__('Unable to get lock for %1', $key));
}

$this->lockService->lock($key);
$this->lockService->lock($key, -1, $this->reason);
}

if (strpos($name, 'save_after') !== false) {
Expand All @@ -54,6 +55,13 @@ private function getOrder(string $name, Observer $observer): OrderInterface
/** @var ShipmentInterface $shipment */
$shipment = $observer->getEvent()->getData('shipment');

return $shipment->getOrder();
if ($shipment) {
$this->reason = 'shipment';
return $shipment->getOrder();
}

$this->reason = 'shipment tracking';
$track = $observer->getEvent()->getData('track');
return $track->getShipment()->getOrder();
}
}
6 changes: 4 additions & 2 deletions Service/LockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,18 @@ public function __construct(
*
* @param string $name lock name
* @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
* @param ?string $reason Reason for locking, will be logged only
* @return bool
*/
public function lock(string $name, int $timeout = -1): bool
public function lock(string $name, int $timeout = -1, ?string $reason = null): bool
{
// Make sure we only lock once per request.
if ($this->alreadyLocked) {
return true;
}

$this->config->addToLog('info', 'Locking: ' . $name);
$message = 'Locking: ' . $name . ($reason ? ' - Reason: ' . $reason : '');
$this->config->addToLog('info', $message);
if ($this->isLockManagerAvailable()) {
return $this->alreadyLocked = $this->lockManager->lock($name, $timeout);
}
Expand Down
44 changes: 44 additions & 0 deletions Service/Mollie/LogException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Mollie\Payment\Service\Mollie;

use Mollie\Payment\Config;

class LogException
{
/**
* @var Config
*/
private $config;

private $messagesToSkip = [
'The \'billingAddress.familyName\' field contains characters that are not allowed'
];

public function __construct(
Config $config,
array $messagesToSkip = []
) {
$this->config = $config;
$this->messagesToSkip = array_merge($this->messagesToSkip, $messagesToSkip);
}

public function execute(\Exception $exception): void
{
$message = method_exists($exception, 'getPlainMessage') ?
$exception->getPlainMessage() :
$exception->getMessage();

if (in_array($message, $this->messagesToSkip)) {
return;
}

$this->config->addTolog('error', $message);
}
}
Loading
Loading