Skip to content

Commit ba68f4b

Browse files
Merge pull request #793 from mollie/release/2.40.0
Release/2.40.0
2 parents ca64e77 + f41dda4 commit ba68f4b

File tree

70 files changed

+827
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+827
-301
lines changed

.github/workflows/templates/magento/configure-mollie.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ bin/magento config:set payment/mollie_methods_bancontact/active 1 &
3131
bin/magento config:set payment/mollie_methods_bancomatpay/active 1 &
3232
bin/magento config:set payment/mollie_methods_belfius/active 1 &
3333
bin/magento config:set payment/mollie_methods_eps/active 1 &
34-
bin/magento config:set payment/mollie_methods_giropay/active 1 &
3534
bin/magento config:set payment/mollie_methods_klarnapaylater/active 1 &
3635
bin/magento config:set payment/mollie_methods_paymentlink/active 1 &
3736
bin/magento config:set payment/mollie_methods_paysafecard/active 1 &
3837
bin/magento config:set payment/mollie_methods_pointofsale/active 1 &
38+
bin/magento config:set payment/mollie_methods_riverty/active 1 &
3939
bin/magento config:set payment/mollie_methods_sofort/active 1 &
40+
bin/magento config:set payment/mollie_methods_trustly/active 1 &
4041
bin/magento config:set payment/mollie_methods_twint/active 1 &
4142

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

49+
# Disable webhooks
4850
bin/magento config:set payment/mollie_general/use_webhooks disabled &
4951

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

63+
# Disable the use of the base currency
64+
bin/magento config:set payment/mollie_general/currency 0 &
65+
66+
# Insert rates, otherwise the currency switcher won't show
67+
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "PLN", 1.0);' &
68+
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "CHF", 1.0);' &
69+
6170
wait
6271

6372
if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,29 @@
11
<?php
2-
/**
3-
* Copyright © Magmodules.eu. All rights reserved.
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
declare(strict_types=1);
77

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

10-
use Exception;
1110
use Magento\Backend\Block\Template\Context;
12-
use Magento\Backend\Block\Widget\Button;
1311
use Magento\Config\Block\System\Config\Form\Field;
14-
use Magento\Framework\App\RequestInterface;
1512
use Magento\Framework\Data\Form\Element\AbstractElement;
1613

17-
/**
18-
* Selftest button class
19-
*/
2014
class Selftest extends Field
2115
{
22-
2316
/**
2417
* @var string
2518
*/
2619
protected $_template = 'Mollie_Payment::system/config/button/selftest.phtml';
2720

28-
/**
29-
* @var RequestInterface
30-
*/
31-
private $request;
32-
33-
/**
34-
* Credentials constructor.
35-
*
36-
* @param Context $context
37-
* @param array $data
38-
*/
39-
public function __construct(
40-
Context $context,
41-
array $data = []
42-
) {
43-
$this->request = $context->getRequest();
44-
parent::__construct($context, $data);
45-
}
46-
4721
/**
4822
* @param AbstractElement $element
4923
*
5024
* @return string
5125
*/
52-
public function render(AbstractElement $element)
26+
public function render(AbstractElement $element): string
5327
{
5428
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
5529
return parent::render($element);
@@ -60,32 +34,16 @@ public function render(AbstractElement $element)
6034
*
6135
* @return string
6236
*/
63-
public function _getElementHtml(AbstractElement $element)
37+
public function _getElementHtml(AbstractElement $element): string
6438
{
6539
return $this->_toHtml();
6640
}
6741

6842
/**
6943
* @return string
7044
*/
71-
public function getSelftestUrl()
45+
public function getSelftestUrl(): string
7246
{
7347
return $this->getUrl('mollie/action/selfTest/');
7448
}
75-
76-
/**
77-
* @return mixed
78-
*/
79-
public function getButtonHtml()
80-
{
81-
$buttonData = ['id' => 'button_test', 'label' => __('Run Self-test')];
82-
try {
83-
$button = $this->getLayout()->createBlock(
84-
Button::class
85-
)->setData($buttonData);
86-
return $button->toHtml();
87-
} catch (Exception $e) {
88-
return false;
89-
}
90-
}
9149
}

Block/Info/Base.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
/**
3-
* Copyright © 2018 Magmodules.eu. All rights reserved.
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

@@ -15,10 +15,12 @@
1515
use Mollie\Payment\Config;
1616
use Mollie\Payment\Helper\General as MollieHelper;
1717
use Mollie\Payment\Model\Methods\Billie;
18+
use Mollie\Payment\Model\Methods\In3;
1819
use Mollie\Payment\Model\Methods\Klarna;
1920
use Mollie\Payment\Model\Methods\Klarnapaylater;
2021
use Mollie\Payment\Model\Methods\Klarnapaynow;
2122
use Mollie\Payment\Model\Methods\Klarnasliceit;
23+
use Mollie\Payment\Model\Methods\Riverty;
2224
use Mollie\Payment\Service\Magento\PaymentLinkUrl;
2325

2426
class Base extends Info
@@ -166,7 +168,15 @@ public function isBuyNowPayLaterMethod(): bool
166168
{
167169
try {
168170
$code = $this->getInfo()->getMethod();
169-
$methods = [Billie::CODE, Klarna::CODE, Klarnapaylater::CODE, Klarnasliceit::CODE, Klarnapaynow::CODE];
171+
$methods = [
172+
Billie::CODE,
173+
In3::CODE,
174+
Klarna::CODE,
175+
Klarnapaylater::CODE,
176+
Klarnasliceit::CODE,
177+
Klarnapaynow::CODE,
178+
Riverty::CODE,
179+
];
170180

171181
if (in_array($code, $methods)) {
172182
return true;

Controller/Adminhtml/Action/SelfTest.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
/**
3-
* Copyright © 2018 Magmodules.eu. All rights reserved.
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

@@ -20,18 +20,10 @@
2020
*/
2121
class SelfTest extends Action
2222
{
23-
/**
24-
* @var \Magento\Framework\App\RequestInterface
25-
*/
26-
private $request;
2723
/**
2824
* @var JsonFactory
2925
*/
3026
private $resultJsonFactory;
31-
/**
32-
* @var TestsHelper
33-
*/
34-
private $testsHelper;
3527
/**
3628
* @var MollieHelper
3729
*/
@@ -44,15 +36,13 @@ class SelfTest extends Action
4436
public function __construct(
4537
Context $context,
4638
JsonFactory $resultJsonFactory,
47-
TestsHelper $testsHelper,
4839
MollieHelper $mollieHelper,
4940
array $tests
5041
) {
51-
$this->request = $context->getRequest();
42+
parent::__construct($context);
43+
5244
$this->resultJsonFactory = $resultJsonFactory;
53-
$this->testsHelper = $testsHelper;
5445
$this->mollieHelper = $mollieHelper;
55-
parent::__construct($context);
5646
$this->tests = $tests;
5747
}
5848

@@ -67,7 +57,6 @@ public function __construct(
6757
public function execute()
6858
{
6959
$result = $this->resultJsonFactory->create();
70-
7160
if (!class_exists('Mollie\Api\CompatibilityChecker')) {
7261
return $this->getPhpApiErrorMessage($result);
7362
}

Controller/Checkout/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected function checkIfLastRealOrder(array $orderIds)
179179
}
180180

181181
try {
182-
$order = $this->orderRepository->get(end($orderIds));
182+
$order = $this->orderRepository->get(array_key_last($orderIds));
183183
$this->checkoutSession->setLastRealOrderId($order->getIncrementId());
184184
} catch (NoSuchEntityException $exception) {
185185
//

Controller/Checkout/Redirect.php

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
/**
3-
* Copyright © 2018 Magmodules.eu. All rights reserved.
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

@@ -11,7 +11,6 @@
1111
use Magento\Framework\App\Action\Action;
1212
use Magento\Framework\App\Action\Context;
1313
use Magento\Framework\Exception\LocalizedException;
14-
use Magento\Framework\View\Result\PageFactory;
1514
use Magento\Payment\Helper\Data as PaymentHelper;
1615
use Magento\Payment\Model\MethodInterface;
1716
use Magento\Sales\Api\Data\OrderInterface;
@@ -20,8 +19,6 @@
2019
use Magento\Sales\Model\Order;
2120
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
2221
use Mollie\Payment\Config;
23-
use Mollie\Payment\Helper\General as MollieHelper;
24-
use Mollie\Payment\Model\Methods\ApplePay;
2522
use Mollie\Payment\Model\Methods\CreditcardVault;
2623
use Mollie\Payment\Model\Mollie;
2724
use Mollie\Payment\Service\Mollie\FormatExceptionMessages;
@@ -38,18 +35,10 @@ class Redirect extends Action
3835
* @var Session
3936
*/
4037
protected $checkoutSession;
41-
/**
42-
* @var PageFactory
43-
*/
44-
protected $resultPageFactory;
4538
/**
4639
* @var PaymentHelper
4740
*/
4841
protected $paymentHelper;
49-
/**
50-
* @var MollieHelper
51-
*/
52-
protected $mollieHelper;
5342
/**
5443
* @var OrderManagementInterface
5544
*/
@@ -81,9 +70,7 @@ class Redirect extends Action
8170
*
8271
* @param Context $context
8372
* @param Session $checkoutSession
84-
* @param PageFactory $resultPageFactory
8573
* @param PaymentHelper $paymentHelper
86-
* @param MollieHelper $mollieHelper
8774
* @param OrderManagementInterface $orderManagement
8875
* @param Config $config
8976
* @param PaymentTokenRepositoryInterface $paymentTokenRepository ,
@@ -94,9 +81,7 @@ class Redirect extends Action
9481
public function __construct(
9582
Context $context,
9683
Session $checkoutSession,
97-
PageFactory $resultPageFactory,
9884
PaymentHelper $paymentHelper,
99-
MollieHelper $mollieHelper,
10085
OrderManagementInterface $orderManagement,
10186
Config $config,
10287
PaymentTokenRepositoryInterface $paymentTokenRepository,
@@ -105,9 +90,7 @@ public function __construct(
10590
FormatExceptionMessages $formatExceptionMessages
10691
) {
10792
$this->checkoutSession = $checkoutSession;
108-
$this->resultPageFactory = $resultPageFactory;
10993
$this->paymentHelper = $paymentHelper;
110-
$this->mollieHelper = $mollieHelper;
11194
$this->orderManagement = $orderManagement;
11295
$this->config = $config;
11396
$this->paymentTokenRepository = $paymentTokenRepository;
@@ -125,50 +108,39 @@ public function execute()
125108
try {
126109
$order = $this->getOrder();
127110
} catch (LocalizedException $exception) {
128-
$this->mollieHelper->addTolog('error', $exception->getMessage());
111+
$this->config->addTolog('error', $exception->getMessage());
129112
return $this->_redirect('checkout/cart');
130113
}
131114

132115
try {
133-
$payment = $order->getPayment();
134-
if (!isset($payment)) {
116+
if ($order->getPayment() === null) {
135117
return $this->_redirect('checkout/cart');
136118
}
137119

138120
$method = $order->getPayment()->getMethod();
139121
$methodInstance = $this->getMethodInstance($method);
140-
if ($methodInstance instanceof Mollie) {
141-
$storeId = $order->getStoreId();
142-
$redirectUrl = $this->redirectUrl->execute($methodInstance, $order);
143-
// This is deprecated since 2.18.0 and will be removed in a future version.
144-
if (!($methodInstance instanceof ApplePay) &&
145-
$this->mollieHelper->useLoadingScreen($storeId)
146-
) {
147-
$resultPage = $this->resultPageFactory->create();
148-
$resultPage->getLayout()->initMessages();
149-
$resultPage->getLayout()->getBlock('mollie_loading')->setMollieRedirect($redirectUrl);
150-
return $resultPage;
151-
} else {
152-
return $this->getResponse()->setRedirect($redirectUrl);
153-
}
154-
} else {
122+
if (!$methodInstance instanceof Mollie) {
155123
$msg = __('Payment Method not found');
156124
$this->messageManager->addErrorMessage($msg);
157-
$this->mollieHelper->addTolog('error', $msg);
125+
$this->config->addTolog('error', $msg);
158126
$this->checkoutSession->restoreQuote();
159127
return $this->_redirect('checkout/cart');
160128
}
129+
130+
return $this->getResponse()->setRedirect(
131+
$this->redirectUrl->execute($methodInstance, $order)
132+
);
161133
} catch (Exception $exception) {
162134
$errorMessage = $this->formatExceptionMessages->execute($exception, $methodInstance ?? null);
163135
$this->messageManager->addErrorMessage($errorMessage);
164-
$this->mollieHelper->addTolog('error', $exception->getMessage());
136+
$this->config->addTolog('error', $exception->getMessage());
165137
$this->checkoutSession->restoreQuote();
166138
$this->cancelUnprocessedOrder($order, $exception->getMessage());
167139
return $this->_redirect('checkout/cart');
168140
}
169141
}
170142

171-
private function cancelUnprocessedOrder(OrderInterface $order, $message)
143+
private function cancelUnprocessedOrder(OrderInterface $order, string $message): void
172144
{
173145
if (!$this->config->cancelFailedOrders()) {
174146
return;
@@ -184,21 +156,16 @@ private function cancelUnprocessedOrder(OrderInterface $order, $message)
184156
$this->orderManagement->cancel($order->getEntityId());
185157
$order->addCommentToStatusHistory($order->getEntityId(), $historyMessage);
186158

187-
$this->mollieHelper->addToLog('info', sprintf('Canceled order %s', $order->getIncrementId()));
159+
$this->config->addToLog('info', sprintf('Canceled order %s', $order->getIncrementId()));
188160
} catch (Exception $e) {
189161
$message = sprintf('Cannot cancel order %s: %s', $order->getIncrementId(), $e->getMessage());
190-
$this->mollieHelper->addToLog('error', $message);
162+
$this->config->addToLog('error', $message);
191163
}
192164
}
193165

194-
/**
195-
* @return OrderInterface
196-
* @throws LocalizedException
197-
*/
198-
private function getOrder()
166+
private function getOrder(): OrderInterface
199167
{
200168
$token = $this->getRequest()->getParam('paymentToken');
201-
202169
if (!$token) {
203170
throw new LocalizedException(__('The required payment token is not available'));
204171
}

0 commit comments

Comments
 (0)