Skip to content

Commit ae070c5

Browse files
Merge pull request #73 from mollie/release/1.8.3
Release/1.8.3
2 parents d80cc20 + e8920e5 commit ae070c5

File tree

6 files changed

+111
-24
lines changed

6 files changed

+111
-24
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ bin/magento config:set payment/mollie_methods_creditcard/use_components 1
4949
# Set a default payment method
5050
bin/magento config:set payment/mollie_general/default_selected_method mollie_methods_ideal
5151

52+
# Enable issuers for KBC
53+
bin/magento config:set payment/mollie_methods_kbc/issuer_list_type radio
54+
5255
# Disable webhooks
5356
bin/magento config:set payment/mollie_general/use_webhooks custom_url
5457

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"require": {
1010
"magento/framework": "*",
1111
"hyva-themes/magento2-hyva-checkout": "^1.3.1",
12-
"mollie/magento2": ">=2.33.0"
12+
"mollie/magento2": ">=2.46.0"
1313
},
1414
"autoload": {
1515
"files": [

src/Mollie_HyvaCheckout/Magewire/Checkout/Payment/Method/WithIssuer.php

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

77
namespace Mollie\HyvaCheckout\Magewire\Checkout\Payment\Method;
@@ -56,8 +56,7 @@ public function mount(): void
5656
{
5757
$quote = $this->sessionCheckout->getQuote();
5858

59-
$mollieApiClient = $this->mollieApiClient->loadByStore();
60-
$this->issuers = $this->getIssuers->execute($mollieApiClient, $this->method, 'list');
59+
$this->issuers = $this->getIssuers->execute($this->method, 'list');
6160

6261
if ($selectedIssuer = $quote->getPayment()->getAdditionalInformation('selected_issuer')) {
6362
$this->selectedIssuer = $selectedIssuer;

src/Mollie_HyvaCheckout/Observer/SalesQuoteCollectTotalsBefore/SetDefaultSelectedPaymentMethod.php

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,39 @@
1010

1111
use Hyva\Checkout\Model\CheckoutInformation\Luma;
1212
use Hyva\Checkout\Model\ConfigData\HyvaThemes\SystemConfigGeneral as HyvaCheckoutConfig;
13-
use Magento\Framework\App\Config\ScopeConfigInterface;
1413
use Magento\Framework\Event\Observer;
1514
use Magento\Framework\Event\ObserverInterface;
1615
use Magento\Framework\Exception\State\InvalidTransitionException;
16+
use Magento\Payment\Api\Data\PaymentMethodInterface;
17+
use Magento\Payment\Api\PaymentMethodListInterface;
1718
use Magento\Quote\Api\Data\PaymentInterfaceFactory;
1819
use Magento\Quote\Api\PaymentMethodManagementInterface;
1920
use Magento\Quote\Model\Quote;
20-
use Magento\Store\Model\ScopeInterface;
21-
use Magento\Store\Model\StoreManagerInterface;
2221
use Mollie\Payment\Config;
2322

2423
class SetDefaultSelectedPaymentMethod implements ObserverInterface
2524
{
2625
private PaymentInterfaceFactory $paymentFactory;
2726
private Config $config;
28-
private StoreManagerInterface $storeManager;
29-
private ScopeConfigInterface $scopeConfig;
3027
private HyvaCheckoutConfig $hyvaCheckoutConfig;
3128
private PaymentMethodManagementInterface $paymentMethodManagement;
29+
private PaymentMethodListInterface $paymentMethodList;
30+
31+
private array $methodList = [];
32+
private int $storeId;
3233

3334
public function __construct(
3435
HyvaCheckoutConfig $hyvaCheckoutConfig,
35-
ScopeConfigInterface $scopeConfig,
3636
Config $config,
3737
PaymentInterfaceFactory $paymentFactory,
38-
StoreManagerInterface $storeManager,
39-
PaymentMethodManagementInterface $paymentMethodManagement
38+
PaymentMethodManagementInterface $paymentMethodManagement,
39+
PaymentMethodListInterface $paymentMethodList
4040
) {
4141
$this->paymentFactory = $paymentFactory;
4242
$this->config = $config;
43-
$this->storeManager = $storeManager;
44-
$this->scopeConfig = $scopeConfig;
4543
$this->hyvaCheckoutConfig = $hyvaCheckoutConfig;
4644
$this->paymentMethodManagement = $paymentMethodManagement;
45+
$this->paymentMethodList = $paymentMethodList;
4746
}
4847

4948
public function execute(Observer $observer): void
@@ -56,13 +55,14 @@ public function execute(Observer $observer): void
5655
return;
5756
}
5857

59-
$defaultMethod = $this->config->getDefaultSelectedMethod($this->storeManager->getStore()->getId());
58+
$this->storeId = (int)$quote->getStoreId();
59+
$defaultMethod = $this->config->getDefaultSelectedMethod();
6060
if (!$defaultMethod) {
6161
return;
6262
}
6363

6464
if ($defaultMethod == 'first_mollie_method') {
65-
$defaultMethod = $this->getFirstAvailableMollieMethod($quote);
65+
$defaultMethod = $this->getFirstAvailableMollieMethod();
6666
}
6767

6868
if ($defaultMethod && !$this->isMethodActive($defaultMethod)) {
@@ -91,11 +91,16 @@ public function execute(Observer $observer): void
9191
*/
9292
private function isMethodActive(string $methodCode): bool
9393
{
94-
return $this->scopeConfig->isSetFlag(
95-
sprintf('payment/%s/active', $methodCode),
96-
ScopeInterface::SCOPE_STORE,
97-
$this->storeManager->getStore()->getCode()
98-
);
94+
$methods = $this->getMethodList();
95+
96+
/** @var PaymentMethodInterface $method */
97+
foreach ($methods as $method) {
98+
if ($method->getCode() === $methodCode) {
99+
return $method->getIsActive();
100+
}
101+
}
102+
103+
return false;
99104
}
100105

101106
private function isHyvaCheckoutActive(): bool
@@ -108,9 +113,9 @@ private function quoteHasActivePaymentMethod(Quote $quote): bool
108113
return $quote->getPayment()->getMethod() !== null;
109114
}
110115

111-
private function getFirstAvailableMollieMethod(Quote $quote): ?string
116+
private function getFirstAvailableMollieMethod(): ?string
112117
{
113-
$methods = $this->paymentMethodManagement->getList($quote->getId());
118+
$methods = $this->getMethodList();
114119

115120
foreach ($methods as $method) {
116121
$methodCode = $method->getCode();
@@ -124,4 +129,14 @@ private function getFirstAvailableMollieMethod(Quote $quote): ?string
124129

125130
return null;
126131
}
132+
133+
private function getMethodList(): array
134+
{
135+
if ($this->methodList !== []) {
136+
return $this->methodList;
137+
}
138+
139+
$this->methodList = $this->paymentMethodList->getList($this->storeId);
140+
return $this->methodList;
141+
}
127142
}

tests/End-2-End/tests/auth/backend-auth.setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
import { test as setup, expect } from '@playwright/test';
77
import BackendLogin from 'Pages/backend/BackendLogin';
88
import path from 'path';
9+
import fs from 'fs';
910

1011
const backendLogin = new BackendLogin();
1112

1213
const authFile = path.join(__dirname, '../../.auth/backend.json');
1314

1415
setup('[C4212591] authenticate', async ({ page }) => {
16+
if (fs.existsSync(authFile)) {
17+
return;
18+
}
19+
1520
await backendLogin.login(page);
1621

1722
await page.context().storageState({ path: authFile });
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright Magmodules.eu. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
import { test, expect } from '@playwright/test';
7+
import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage";
8+
import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction";
9+
import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage";
10+
import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage";
11+
import OrdersPage from "Pages/backend/OrdersPage";
12+
import CartPage from "Pages/frontend/CartPage";
13+
14+
const checkoutPaymentPage = new CheckoutPaymentPage();
15+
const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction();
16+
const mollieHostedPaymentPage = new MollieHostedPaymentPage(expect);
17+
const checkoutSuccessPage = new CheckoutSuccessPage(expect);
18+
const ordersPage = new OrdersPage();
19+
const cartPage = new CartPage();
20+
21+
const testCases = [
22+
{status: 'paid', orderStatus: 'Processing', title: '[C4251742] Validate the submission of an order with KBC/CBC as payment method and payment mark as "Paid"'},
23+
{status: 'failed', orderStatus: 'Canceled', title: '[C4251743] Validate the submission of an order with KBC/CBC as payment method and payment mark as "Failed"'},
24+
{status: 'expired', orderStatus: 'Canceled', title: '[C4251744] Validate the submission of an order with KBC/CBC as payment method and payment mark as "Expired"'},
25+
{status: 'canceled', orderStatus: 'Canceled', title: '[C4251745] Validate the submission of an order with KBC/CBC as payment method and payment mark as "Cancelled"'},
26+
];
27+
28+
for (const testCase of testCases) {
29+
test(testCase.title, async ({ page }) => {
30+
test.skip(!process.env.mollie_available_methods.includes('kbc'), 'Skipping test as KBC is not available');
31+
32+
await visitCheckoutPayment.visit(page);
33+
34+
await checkoutPaymentPage.selectPaymentMethod(page, 'KBC');
35+
await checkoutPaymentPage.placeOrder(page);
36+
37+
const values = ['CBC', 'KBC'];
38+
const randomIndex = Math.floor(Math.random() * values.length);
39+
40+
mollieHostedPaymentPage.selectPaymentMethod(page, values[randomIndex]);
41+
await mollieHostedPaymentPage.selectStatus(page, testCase.status);
42+
43+
if (testCase.status === 'paid') {
44+
await checkoutSuccessPage.assertThatOrderSuccessPageIsShown(page);
45+
}
46+
47+
if (testCase.status === 'canceled') {
48+
await cartPage.assertCartPageIsShown(page);
49+
}
50+
51+
if (checkoutPaymentPage.orderId) {
52+
await ordersPage.openOrderById(page, checkoutPaymentPage.orderId);
53+
} else if (mollieHostedPaymentPage.incrementId) {
54+
await ordersPage.openByIncrementId(page, mollieHostedPaymentPage.incrementId);
55+
} else {
56+
await ordersPage.openLatestOrder(page);
57+
}
58+
59+
if (testCase.status === 'expired') {
60+
await ordersPage.callFetchStatus(page);
61+
}
62+
63+
await ordersPage.assertOrderStatusIs(page, testCase.orderStatus);
64+
});
65+
}

0 commit comments

Comments
 (0)