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.40.0 #793

Merged
merged 36 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
77680e1
Feature: End 2 End tests for Blik
michielgerritsen Mar 21, 2024
ac56c57
Merge branch 'master' into feature/blik-end-2-end-tests
michielgerritsen May 6, 2024
41d8deb
Configure environment for Blik
michielgerritsen May 6, 2024
cdc3113
Order product twice to reach ALMA's minimum order amount
michielgerritsen May 9, 2024
9420f0d
Merge branch 'master' into feature/blik-end-2-end-tests
michielgerritsen May 23, 2024
3dd2b01
Feature: Added Riverty
michielgerritsen Jun 24, 2024
eb6da12
Bugfix: Force Alma to use the orders API
michielgerritsen Jun 24, 2024
5cafcc2
Bugfix: Remove loading page to prevent state issues #786
michielgerritsen Jul 1, 2024
0a7d74f
[DOK-138] handle failed status
yaroslav-qlicks Jul 3, 2024
c65d4c4
Improvement: Remove Giropay
michielgerritsen Jul 4, 2024
2e5be76
Feature: Add Trustly
michielgerritsen Jul 4, 2024
8d4791d
Merge branch 'feature/blik-end-2-end-tests' into release-week-26
michielgerritsen Jul 4, 2024
a903057
Merge branch 'bugfix/force-alma-on-orders-api' into release-week-26
michielgerritsen Jul 4, 2024
781d67b
Merge branch 'bugfix/remove-loading-page' into release-week-26
michielgerritsen Jul 4, 2024
ca5982e
Merge branch 'improvement/remove-giropay' into release-week-26
michielgerritsen Jul 4, 2024
d7ca442
Feature: Add Trustly
michielgerritsen Jul 4, 2024
e6178b6
Merge branch 'feature/add-trustly' into release-week-26
michielgerritsen Jul 4, 2024
80a0732
Merge branch 'feature/riverty' into release-week-26
michielgerritsen Jul 4, 2024
8b813b5
Improvement: Include date of birth field in the self-test
michielgerritsen Jul 4, 2024
a576a53
Bugfix: Prevent new transactions when the previous one is already pai…
michielgerritsen Jul 9, 2024
62aa402
Bugfix: Check available methods
michielgerritsen Jul 9, 2024
5583790
Merge branch 'improvement/check-dob-field' into release-week-26
michielgerritsen Jul 9, 2024
5e94bf5
Merge branch 'bugfix/check-available-methods' into release-week-26
michielgerritsen Jul 9, 2024
046ff03
Merge branch 'bugfix/prevent-new-transaction-when-already-paid' into …
michielgerritsen Jul 9, 2024
810b5e5
Re-enable issuer selection
michielgerritsen Jul 11, 2024
0936ffa
Remove unused code
michielgerritsen Jul 11, 2024
68d1f34
Use French address for Alma when testing
michielgerritsen Jul 11, 2024
281605f
Limit used methods by status = activated
michielgerritsen Jul 11, 2024
c1820ac
Test fix
michielgerritsen Jul 11, 2024
1fb02f2
Limit methods by country
michielgerritsen Jul 11, 2024
a0d9b61
Fix test
michielgerritsen Jul 11, 2024
931127b
Disable ALMA
michielgerritsen Jul 11, 2024
5b0cbbd
Abort payment attempt when the order is already paid
michielgerritsen Jul 11, 2024
ca7d143
Merge branch 'DOK-138' into release-week-26
michielgerritsen Jul 11, 2024
f477882
Fix Riverty E2E tests
michielgerritsen Jul 11, 2024
f41dda4
Version bump
Marvin-Magmodules Jul 11, 2024
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
11 changes: 10 additions & 1 deletion .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ bin/magento config:set payment/mollie_methods_bancontact/active 1 &
bin/magento config:set payment/mollie_methods_bancomatpay/active 1 &
bin/magento config:set payment/mollie_methods_belfius/active 1 &
bin/magento config:set payment/mollie_methods_eps/active 1 &
bin/magento config:set payment/mollie_methods_giropay/active 1 &
bin/magento config:set payment/mollie_methods_klarnapaylater/active 1 &
bin/magento config:set payment/mollie_methods_paymentlink/active 1 &
bin/magento config:set payment/mollie_methods_paysafecard/active 1 &
bin/magento config:set payment/mollie_methods_pointofsale/active 1 &
bin/magento config:set payment/mollie_methods_riverty/active 1 &
bin/magento config:set payment/mollie_methods_sofort/active 1 &
bin/magento config:set payment/mollie_methods_trustly/active 1 &
bin/magento config:set payment/mollie_methods_twint/active 1 &

# Enable Components
Expand All @@ -45,6 +46,7 @@ bin/magento config:set payment/mollie_methods_creditcard/use_components 1 &
# Enable QR
bin/magento config:set payment/mollie_methods_ideal/add_qr 1 &

# Disable webhooks
bin/magento config:set payment/mollie_general/use_webhooks disabled &

# Configure currency for the swiss store view
Expand All @@ -58,6 +60,13 @@ bin/magento config:set payment/mollie_general/currency 0 --scope=ch &
bin/magento config:set currency/options/default PLN --scope=pl &
bin/magento config:set payment/mollie_general/currency 0 --scope=pl &

# Disable the use of the base currency
bin/magento config:set payment/mollie_general/currency 0 &

# Insert rates, otherwise the currency switcher won't show
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "PLN", 1.0);' &
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "CHF", 1.0);' &

wait

if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
Expand Down
52 changes: 5 additions & 47 deletions Block/Adminhtml/System/Config/Button/Selftest.php
Original file line number Diff line number Diff line change
@@ -1,55 +1,29 @@
<?php
/**
* Copyright © Magmodules.eu. All rights reserved.
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Mollie\Payment\Block\Adminhtml\System\Config\Button;

use Exception;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;

/**
* Selftest button class
*/
class Selftest extends Field
{

/**
* @var string
*/
protected $_template = 'Mollie_Payment::system/config/button/selftest.phtml';

/**
* @var RequestInterface
*/
private $request;

/**
* Credentials constructor.
*
* @param Context $context
* @param array $data
*/
public function __construct(
Context $context,
array $data = []
) {
$this->request = $context->getRequest();
parent::__construct($context, $data);
}

/**
* @param AbstractElement $element
*
* @return string
*/
public function render(AbstractElement $element)
public function render(AbstractElement $element): string
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
Expand All @@ -60,32 +34,16 @@ public function render(AbstractElement $element)
*
* @return string
*/
public function _getElementHtml(AbstractElement $element)
public function _getElementHtml(AbstractElement $element): string
{
return $this->_toHtml();
}

/**
* @return string
*/
public function getSelftestUrl()
public function getSelftestUrl(): string
{
return $this->getUrl('mollie/action/selfTest/');
}

/**
* @return mixed
*/
public function getButtonHtml()
{
$buttonData = ['id' => 'button_test', 'label' => __('Run Self-test')];
try {
$button = $this->getLayout()->createBlock(
Button::class
)->setData($buttonData);
return $button->toHtml();
} catch (Exception $e) {
return false;
}
}
}
16 changes: 13 additions & 3 deletions Block/Info/Base.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2018 Magmodules.eu. All rights reserved.
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -15,10 +15,12 @@
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
use Mollie\Payment\Model\Methods\Billie;
use Mollie\Payment\Model\Methods\In3;
use Mollie\Payment\Model\Methods\Klarna;
use Mollie\Payment\Model\Methods\Klarnapaylater;
use Mollie\Payment\Model\Methods\Klarnapaynow;
use Mollie\Payment\Model\Methods\Klarnasliceit;
use Mollie\Payment\Model\Methods\Riverty;
use Mollie\Payment\Service\Magento\PaymentLinkUrl;

class Base extends Info
Expand Down Expand Up @@ -166,7 +168,15 @@ public function isBuyNowPayLaterMethod(): bool
{
try {
$code = $this->getInfo()->getMethod();
$methods = [Billie::CODE, Klarna::CODE, Klarnapaylater::CODE, Klarnasliceit::CODE, Klarnapaynow::CODE];
$methods = [
Billie::CODE,
In3::CODE,
Klarna::CODE,
Klarnapaylater::CODE,
Klarnasliceit::CODE,
Klarnapaynow::CODE,
Riverty::CODE,
];

if (in_array($code, $methods)) {
return true;
Expand Down
19 changes: 4 additions & 15 deletions Controller/Adminhtml/Action/SelfTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2018 Magmodules.eu. All rights reserved.
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -20,18 +20,10 @@
*/
class SelfTest extends Action
{
/**
* @var \Magento\Framework\App\RequestInterface
*/
private $request;
/**
* @var JsonFactory
*/
private $resultJsonFactory;
/**
* @var TestsHelper
*/
private $testsHelper;
/**
* @var MollieHelper
*/
Expand All @@ -44,15 +36,13 @@ class SelfTest extends Action
public function __construct(
Context $context,
JsonFactory $resultJsonFactory,
TestsHelper $testsHelper,
MollieHelper $mollieHelper,
array $tests
) {
$this->request = $context->getRequest();
parent::__construct($context);

$this->resultJsonFactory = $resultJsonFactory;
$this->testsHelper = $testsHelper;
$this->mollieHelper = $mollieHelper;
parent::__construct($context);
$this->tests = $tests;
}

Expand All @@ -67,7 +57,6 @@ public function __construct(
public function execute()
{
$result = $this->resultJsonFactory->create();

if (!class_exists('Mollie\Api\CompatibilityChecker')) {
return $this->getPhpApiErrorMessage($result);
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Checkout/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function checkIfLastRealOrder(array $orderIds)
}

try {
$order = $this->orderRepository->get(end($orderIds));
$order = $this->orderRepository->get(array_key_last($orderIds));
$this->checkoutSession->setLastRealOrderId($order->getIncrementId());
} catch (NoSuchEntityException $exception) {
//
Expand Down
63 changes: 15 additions & 48 deletions Controller/Checkout/Redirect.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2018 Magmodules.eu. All rights reserved.
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -11,7 +11,6 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Result\PageFactory;
use Magento\Payment\Helper\Data as PaymentHelper;
use Magento\Payment\Model\MethodInterface;
use Magento\Sales\Api\Data\OrderInterface;
Expand All @@ -20,8 +19,6 @@
use Magento\Sales\Model\Order;
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
use Mollie\Payment\Model\Methods\ApplePay;
use Mollie\Payment\Model\Methods\CreditcardVault;
use Mollie\Payment\Model\Mollie;
use Mollie\Payment\Service\Mollie\FormatExceptionMessages;
Expand All @@ -38,18 +35,10 @@ class Redirect extends Action
* @var Session
*/
protected $checkoutSession;
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* @var PaymentHelper
*/
protected $paymentHelper;
/**
* @var MollieHelper
*/
protected $mollieHelper;
/**
* @var OrderManagementInterface
*/
Expand Down Expand Up @@ -81,9 +70,7 @@ class Redirect extends Action
*
* @param Context $context
* @param Session $checkoutSession
* @param PageFactory $resultPageFactory
* @param PaymentHelper $paymentHelper
* @param MollieHelper $mollieHelper
* @param OrderManagementInterface $orderManagement
* @param Config $config
* @param PaymentTokenRepositoryInterface $paymentTokenRepository ,
Expand All @@ -94,9 +81,7 @@ class Redirect extends Action
public function __construct(
Context $context,
Session $checkoutSession,
PageFactory $resultPageFactory,
PaymentHelper $paymentHelper,
MollieHelper $mollieHelper,
OrderManagementInterface $orderManagement,
Config $config,
PaymentTokenRepositoryInterface $paymentTokenRepository,
Expand All @@ -105,9 +90,7 @@ public function __construct(
FormatExceptionMessages $formatExceptionMessages
) {
$this->checkoutSession = $checkoutSession;
$this->resultPageFactory = $resultPageFactory;
$this->paymentHelper = $paymentHelper;
$this->mollieHelper = $mollieHelper;
$this->orderManagement = $orderManagement;
$this->config = $config;
$this->paymentTokenRepository = $paymentTokenRepository;
Expand All @@ -125,50 +108,39 @@ public function execute()
try {
$order = $this->getOrder();
} catch (LocalizedException $exception) {
$this->mollieHelper->addTolog('error', $exception->getMessage());
$this->config->addTolog('error', $exception->getMessage());
return $this->_redirect('checkout/cart');
}

try {
$payment = $order->getPayment();
if (!isset($payment)) {
if ($order->getPayment() === null) {
return $this->_redirect('checkout/cart');
}

$method = $order->getPayment()->getMethod();
$methodInstance = $this->getMethodInstance($method);
if ($methodInstance instanceof Mollie) {
$storeId = $order->getStoreId();
$redirectUrl = $this->redirectUrl->execute($methodInstance, $order);
// This is deprecated since 2.18.0 and will be removed in a future version.
if (!($methodInstance instanceof ApplePay) &&
$this->mollieHelper->useLoadingScreen($storeId)
) {
$resultPage = $this->resultPageFactory->create();
$resultPage->getLayout()->initMessages();
$resultPage->getLayout()->getBlock('mollie_loading')->setMollieRedirect($redirectUrl);
return $resultPage;
} else {
return $this->getResponse()->setRedirect($redirectUrl);
}
} else {
if (!$methodInstance instanceof Mollie) {
$msg = __('Payment Method not found');
$this->messageManager->addErrorMessage($msg);
$this->mollieHelper->addTolog('error', $msg);
$this->config->addTolog('error', $msg);
$this->checkoutSession->restoreQuote();
return $this->_redirect('checkout/cart');
}

return $this->getResponse()->setRedirect(
$this->redirectUrl->execute($methodInstance, $order)
);
} catch (Exception $exception) {
$errorMessage = $this->formatExceptionMessages->execute($exception, $methodInstance ?? null);
$this->messageManager->addErrorMessage($errorMessage);
$this->mollieHelper->addTolog('error', $exception->getMessage());
$this->config->addTolog('error', $exception->getMessage());
$this->checkoutSession->restoreQuote();
$this->cancelUnprocessedOrder($order, $exception->getMessage());
return $this->_redirect('checkout/cart');
}
}

private function cancelUnprocessedOrder(OrderInterface $order, $message)
private function cancelUnprocessedOrder(OrderInterface $order, string $message): void
{
if (!$this->config->cancelFailedOrders()) {
return;
Expand All @@ -184,21 +156,16 @@ private function cancelUnprocessedOrder(OrderInterface $order, $message)
$this->orderManagement->cancel($order->getEntityId());
$order->addCommentToStatusHistory($order->getEntityId(), $historyMessage);

$this->mollieHelper->addToLog('info', sprintf('Canceled order %s', $order->getIncrementId()));
$this->config->addToLog('info', sprintf('Canceled order %s', $order->getIncrementId()));
} catch (Exception $e) {
$message = sprintf('Cannot cancel order %s: %s', $order->getIncrementId(), $e->getMessage());
$this->mollieHelper->addToLog('error', $message);
$this->config->addToLog('error', $message);
}
}

/**
* @return OrderInterface
* @throws LocalizedException
*/
private function getOrder()
private function getOrder(): OrderInterface
{
$token = $this->getRequest()->getParam('paymentToken');

if (!$token) {
throw new LocalizedException(__('The required payment token is not available'));
}
Expand Down
Loading
Loading