Skip to content

Commit

Permalink
Merge pull request #629 from mollie/release/2.24.0
Browse files Browse the repository at this point in the history
Release/2.24.0
  • Loading branch information
Marvin-Magmodules authored Apr 11, 2023
2 parents 7553c8a + 3da0523 commit 2d52959
Show file tree
Hide file tree
Showing 47 changed files with 1,261 additions and 286 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- opened
- labeled

concurrency: e2e-tests

jobs:
secrets-gate:
# Only run tests if the pull request is opened or labeled with run_e2e_tests
Expand Down Expand Up @@ -36,21 +38,18 @@ jobs:
})
e2e-tests:
concurrency: e2e-tests

needs:
- secrets-gate
# Only run this job if the secret is set
if: needs.secrets-gate.outputs.is-secret-set == 'true'
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.3.7-p3
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.5-p1
MAGENTO_VERSION: 2.4.6
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.PHP_VERSION }}
Expand Down Expand Up @@ -81,7 +80,7 @@ jobs:
run: |
sed -i '/version/d' ./composer.json && \
docker cp $(pwd) magento-project-community-edition:/data/extensions/ && \
docker exec magento-project-community-edition composer require mollie/magento2:@dev --no-plugins
docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev
- name: Activate the extension
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
include:
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7-p3
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
MAGENTO_VERSION: 2.4.6
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -27,7 +27,7 @@ jobs:
run: sed -i '/version/d' ./composer.json

- name: Upload the code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2:@dev --no-plugins
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade"
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ jobs:
php-73:
runs-on: ubuntu-latest
steps:
- uses: StephaneBour/[email protected]
with:
dir: './'
- uses: prestashop/github-action-php-lint/[email protected]

php-74:
runs-on: ubuntu-latest
steps:
- uses: StephaneBour/[email protected]
with:
dir: './'
- uses: prestashop/github-action-php-lint/[email protected]

php-81:
runs-on: ubuntu-latest
steps:
- uses: StephaneBour/[email protected]
with:
dir: './'
- uses: prestashop/github-action-php-lint/[email protected]

php-82:
runs-on: ubuntu-latest
steps:
- uses: prestashop/github-action-php-lint/[email protected]
6 changes: 4 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ jobs:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
MAGENTO_VERSION: 2.4.6
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6

runs-on: ubuntu-latest
steps:
Expand All @@ -27,7 +29,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extensions in Magento
run: docker exec magento-project-community-edition composer require mollie/magento2:@dev --no-plugins
run: docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ jobs:
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7-p3
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
MAGENTO_VERSION: 2.4.6
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6

runs-on: ubuntu-latest
steps:
Expand All @@ -29,7 +31,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extension in Magento
run: docker exec magento-project-community-edition composer require mollie/magento2:@dev --no-plugins
run: docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Run setup:di:compile
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
2 changes: 1 addition & 1 deletion .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bin/magento config:set payment/mollie_general/use_webhooks disabled &
wait

if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
./retry "php bin/magento module:disable Magento_TwoFactorAuth"
./retry "php bin/magento module:disable Magento_TwoFactorAuth -f"
fi


Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
MAGENTO_VERSION: 2.4.6
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -25,7 +27,7 @@ jobs:
run: sed -i '/version/d' ./composer.json

- name: Upload the code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2:@dev --no-plugins
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
Expand Down
21 changes: 13 additions & 8 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Config
const GENERAL_DASHBOARD_URL_PAYMENTS_API = 'payment/mollie_general/dashboard_url_payments_api';
const GENERAL_ENABLE_MAGENTO_VAULT = 'payment/mollie_general/enable_magento_vault';
const GENERAL_ENABLE_SECOND_CHANCE_EMAIL = 'payment/mollie_general/enable_second_chance_email';
const GENERAL_ENCRYPT_PAYMENT_DETAILS = 'payment/mollie_general/encrypt_payment_details';
const GENERAL_INCLUDE_SHIPPING_IN_SURCHARGE = 'payment/mollie_general/include_shipping_in_surcharge';
const GENERAL_INVOICE_NOTIFY = 'payment/mollie_general/invoice_notify';
const GENERAL_LOCALE = 'payment/mollie_general/locale';
Expand Down Expand Up @@ -209,27 +210,26 @@ public function getApiKey($storeId = null)
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (test modus)');
}
$decryptedApiKey = $this->encryptor->decrypt($apiKey);
if (!preg_match('/^test_\w+$/', $decryptedApiKey)) {

if (!preg_match('/^test_\w+$/', $apiKey)) {
$this->addToLog('error', 'Mollie set to test modus, but API key does not start with "test_"');
}

$keys[$storeId] = $decryptedApiKey;
return $decryptedApiKey;
$keys[$storeId] = $apiKey;
return $apiKey;
}

$apiKey = trim($this->getPath(static::GENERAL_APIKEY_LIVE, $storeId) ?? '');
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (live modus)');
}

$decryptedApiKey = $this->encryptor->decrypt($apiKey);
if (!preg_match('/^live_\w+$/', $decryptedApiKey)) {
if (!preg_match('/^live_\w+$/', $apiKey)) {
$this->addToLog('error', 'Mollie set to live modus, but API key does not start with "live_"');
}

$keys[$storeId] = $decryptedApiKey;
return $decryptedApiKey;
$keys[$storeId] = $apiKey;
return $apiKey;
}

/**
Expand Down Expand Up @@ -679,6 +679,11 @@ public function isMultishippingEnabled(): bool
return $this->moduleManager->isEnabled('Mollie_Multishipping');
}

public function encryptPaymentDetails($storeId = null): bool
{
return $this->isSetFlag(static::GENERAL_ENCRYPT_PAYMENT_DETAILS, $storeId);
}

/**
* @param $method
* @return string
Expand Down
15 changes: 2 additions & 13 deletions Controller/Adminhtml/Action/Apikey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Store\Model\ScopeInterface;
use Mollie\Payment\Helper\General as MollieHelper;
use Mollie\Payment\Helper\Tests as TestsHelper;
Expand Down Expand Up @@ -45,11 +44,6 @@ class Apikey extends Action
*/
private $scopeConfig;

/**
* @var EncryptorInterface
*/
private $encryptor;

/**
* Apikey constructor.
*
Expand All @@ -58,22 +52,19 @@ class Apikey extends Action
* @param TestsHelper $testsHelper
* @param MollieHelper $mollieHelper
* @param ScopeConfigInterface $scopeConfig
* @param EncryptorInterface $encryptor
*/
public function __construct(
Context $context,
JsonFactory $resultJsonFactory,
TestsHelper $testsHelper,
MollieHelper $mollieHelper,
ScopeConfigInterface $scopeConfig,
EncryptorInterface $encryptor
ScopeConfigInterface $scopeConfig
) {
$this->request = $context->getRequest();
$this->resultJsonFactory = $resultJsonFactory;
$this->testsHelper = $testsHelper;
$this->mollieHelper = $mollieHelper;
$this->scopeConfig = $scopeConfig;
$this->encryptor = $encryptor;

parent::__construct($context);
}
Expand Down Expand Up @@ -109,9 +100,7 @@ protected function _isAllowed()
private function getKey(string $type): string
{
if (!$this->request->getParam($type . '_key') || $this->request->getParam($type . '_key') == '******') {
$value = $this->scopeConfig->getValue('payment/mollie_general/apikey_' . $type, ScopeInterface::SCOPE_STORE);

return $this->encryptor->decrypt($value);
return $this->scopeConfig->getValue('payment/mollie_general/apikey_' . $type, ScopeInterface::SCOPE_STORE);
}

return $this->request->getParam($type . '_key');
Expand Down
39 changes: 11 additions & 28 deletions Controller/Checkout/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
use Mollie\Payment\Model\Methods\ApplePay;
use Mollie\Payment\Model\Methods\Creditcard;
use Mollie\Payment\Model\Methods\CreditcardVault;
use Mollie\Payment\Model\Methods\Directdebit;
use Mollie\Payment\Model\Mollie;
use Mollie\Payment\Service\Mollie\Order\RedirectUrl;

/**
* Class Redirect
Expand Down Expand Up @@ -67,6 +66,11 @@ class Redirect extends Action
*/
private $orderRepository;

/**
* @var RedirectUrl
*/
private $redirectUrl;

/**
* Redirect constructor.
*
Expand All @@ -79,6 +83,7 @@ class Redirect extends Action
* @param Config $config
* @param PaymentTokenRepositoryInterface $paymentTokenRepository,
* @param OrderRepositoryInterface $orderRepository
* @param RedirectUrl $redirectUrl
*/
public function __construct(
Context $context,
Expand All @@ -89,7 +94,8 @@ public function __construct(
OrderManagementInterface $orderManagement,
Config $config,
PaymentTokenRepositoryInterface $paymentTokenRepository,
OrderRepositoryInterface $orderRepository
OrderRepositoryInterface $orderRepository,
RedirectUrl $redirectUrl
) {
$this->checkoutSession = $checkoutSession;
$this->resultPageFactory = $resultPageFactory;
Expand All @@ -99,6 +105,7 @@ public function __construct(
$this->config = $config;
$this->paymentTokenRepository = $paymentTokenRepository;
$this->orderRepository = $orderRepository;
$this->redirectUrl = $redirectUrl;
parent::__construct($context);
}

Expand All @@ -124,7 +131,7 @@ public function execute()
$methodInstance = $this->getMethodInstance($method);
if ($methodInstance instanceof Mollie) {
$storeId = $order->getStoreId();
$redirectUrl = $this->startTransaction($methodInstance, $order);
$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)
Expand Down Expand Up @@ -233,30 +240,6 @@ private function getOrder()
return $this->orderRepository->get($model->getOrderId());
}

/**
* @param Mollie $methodInstance
* @param OrderInterface $order
* @return mixed
*/
private function startTransaction(Mollie $methodInstance, OrderInterface $order)
{
$redirectUrl = $methodInstance->startTransaction($order);

/**
* Directdebit does not return an url when in test mode.
*/
if (!$redirectUrl && $methodInstance instanceof Directdebit && $this->config->isTestMode()) {
$redirectUrl = $this->_url->getUrl('checkout/onepage/success/');
}

$emptyUrlAllowed = $methodInstance instanceof ApplePay || $methodInstance instanceof Creditcard;
if (!$redirectUrl && $emptyUrlAllowed) {
$redirectUrl = $this->_url->getUrl('checkout/onepage/success/');
}

return $redirectUrl;
}

private function getMethodInstance(string $method): MethodInterface
{
$methodInstance = $this->paymentHelper->getMethodInstance($method);
Expand Down
13 changes: 7 additions & 6 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,22 @@ public function getApiKey($storeId = null)
if (empty($apiKey)) {
$this->addTolog('error', 'Mollie API key not set (test modus)');
}
$decryptedApiKey = $this->encryptor->decrypt($apiKey);
if (!preg_match('/^test_\w+$/', $decryptedApiKey)) {

if (!preg_match('/^test_\w+$/', $apiKey)) {
$this->addTolog('error', 'Mollie set to test modus, but API key does not start with "test_"');
}
$this->apiKey[$storeId] = $decryptedApiKey;

$this->apiKey[$storeId] = $apiKey;
} else {
$apiKey = trim($this->getStoreConfig(self::XML_PATH_LIVE_APIKEY, $storeId) ?? '');
if (empty($apiKey)) {
$this->addTolog('error', 'Mollie API key not set (live modus)');
}
$decryptedApiKey = $this->encryptor->decrypt($apiKey);
if (!preg_match('/^live_\w+$/', $decryptedApiKey)) {

if (!preg_match('/^live_\w+$/', $apiKey)) {
$this->addTolog('error', 'Mollie set to live modus, but API key does not start with "live_"');
}
$this->apiKey[$storeId] = $decryptedApiKey;
$this->apiKey[$storeId] = $apiKey;
}

return $this->apiKey[$storeId];
Expand Down
Loading

0 comments on commit 2d52959

Please sign in to comment.