Skip to content

Commit

Permalink
Merge pull request #784 from mollie/release/2.39.0
Browse files Browse the repository at this point in the history
Release/2.39.0
  • Loading branch information
Marvin-Magmodules authored Jun 17, 2024
2 parents 0380bb3 + bee0b12 commit ca64e77
Show file tree
Hide file tree
Showing 43 changed files with 239 additions and 309 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: End-2-end
on:
push:
tags:
- '*'
pull_request:
types:
- opened
Expand Down Expand Up @@ -49,7 +52,7 @@ jobs:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p4
MAGENTO_VERSION: 2.4.6-p5
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.PHP_VERSION }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
php-82:
runs-on: ubuntu-latest
steps:
- uses: prestashop/github-action-php-lint/8.2@v2.1
- uses: prestashop/github-action-php-lint/8.2@v2.1
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7

runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7

runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand Down
53 changes: 53 additions & 0 deletions Block/Adminhtml/System/Config/Button/Documentation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/*
* 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\Data\Form\Element\AbstractElement;
use Mollie\Payment\Config;

/**
* Version check button class
*/
class Documentation extends Field
{
/**
* @var string
*/
protected $_template = 'Mollie_Payment::system/config/button/documentation.phtml';

public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}

public function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}

/**
* @return mixed
*/
public function getButtonHtml()
{
$buttonData = ['id' => 'mm-mollie-button_version', 'label' => __('Check for latest versions')];
try {
$button = $this->getLayout()->createBlock(
Button::class
)->setData($buttonData);
return $button->toHtml();
} catch (Exception $e) {
return false;
}
}
}
2 changes: 1 addition & 1 deletion Controller/Checkout/Process.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/**
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
36 changes: 3 additions & 33 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Mollie\Payment\Logger\MollieLogger;
use Magento\SalesRule\Model\Coupon;
use Magento\SalesRule\Model\ResourceModel\Coupon\Usage as CouponUsage;
use Mollie\Payment\Service\Mollie\PaymentMethods;
use Mollie\Payment\Service\Order\CancelOrder;
use Mollie\Payment\Service\Order\MethodCode;
use Mollie\Payment\Service\Order\Transaction;
Expand Down Expand Up @@ -615,41 +616,10 @@ public function getBanktransferDueDate($storeId = 0)
*
* @return array
*/
public function getAllActiveMethods($storeId)
public function getAllActiveMethods($storeId): array
{
$activeMethods = [];
$methodCodes = [
'mollie_methods_applepay',
'mollie_methods_alma',
'mollie_methods_bancomatpay',
'mollie_methods_bancontact',
'mollie_methods_banktransfer',
'mollie_methods_belfius',
'mollie_methods_billie',
'mollie_methods_blik',
'mollie_methods_creditcard',
'mollie_methods_directdebit',
'mollie_methods_eps',
'mollie_methods_giftcard',
'mollie_methods_giropay',
'mollie_methods_ideal',
'mollie_methods_in3',
'mollie_methods_kbc',
'mollie_methods_klarna',
'mollie_methods_klarnapaylater',
'mollie_methods_klarnapaynow',
'mollie_methods_klarnasliceit',
'mollie_methods_voucher',
'mollie_methods_mybank',
'mollie_methods_paypal',
'mollie_methods_paysafecard',
'mollie_methods_pointofsale',
'mollie_methods_przelewy24',
'mollie_methods_sofort',
'mollie_methods_twint',
];

foreach ($methodCodes as $methodCode) {
foreach (PaymentMethods::METHODS as $methodCode) {
$activePath = 'payment/' . $methodCode . '/active';
$active = $this->getStoreConfig($activePath, $storeId);

Expand Down
6 changes: 3 additions & 3 deletions Model/Adminhtml/Source/MolliePaymentMethod.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/**
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down Expand Up @@ -30,7 +30,7 @@ public function toOptionArray()
return array_merge(
[['value' => '', 'label' => __('None')]],
[['value' => 'first_mollie_method', 'label' => __('First available Mollie method')]],
$this->methods->getCodeswithTitle()
$this->methods->getCodesWithTitle()
);
}
}
}
2 changes: 1 addition & 1 deletion Model/Client/Orders/Processors/SuccessfulPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private function handleWebhookCall(OrderInterface $order, MollieOrder $mollieOrd
$payment->setTransactionId($paymentId);
$payment->setCurrencyCode($order->getBaseCurrencyCode());

if ($mollieOrder->isPaid()) {
if ($order->getState() != \Magento\Sales\Model\Order::STATE_PROCESSING && $mollieOrder->isPaid()) {
$payment->setIsTransactionClosed(true);
$payment->registerCaptureNotification($order->getBaseGrandTotal(), true);
}
Expand Down
7 changes: 6 additions & 1 deletion Model/Client/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,13 @@ public function processResponse(OrderInterface $order, $payment)

$this->eventManager->dispatch('mollie_process_response', $eventData);
$this->eventManager->dispatch('mollie_process_response_payments_api', $eventData);

$this->mollieHelper->addTolog('response', $payment);

// The order is canceled before but now restarted, so uncancel the order.
if ($order->getState() == Order::STATE_CANCELED) {
$this->mollieHelper->uncancelOrder($order);
}

$order->getPayment()->setAdditionalInformation('checkout_url', $payment->getCheckoutUrl());
$order->getPayment()->setAdditionalInformation('checkout_type', self::CHECKOUT_TYPE);
$order->getPayment()->setAdditionalInformation('payment_status', $payment->status);
Expand Down
3 changes: 2 additions & 1 deletion Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ public function getOrderIdsByTransactionId(string $transactionId): array
public function getIssuers(MollieApiClient $mollieApi = null, string $method, string $issuerListType, int $count = 0): ?array
{
$issuers = [];
if (empty($mollieApi) || $issuerListType == 'none') {
// iDeal 2.0 does not have issuers anymore.
if (empty($mollieApi) || $issuerListType == 'none' || $method == 'mollie_methods_ideal') {
return $issuers;
}

Expand Down
42 changes: 6 additions & 36 deletions Model/MollieConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Mollie\Payment\Service\Mollie\ApplePay\SupportedNetworks;
use Mollie\Payment\Service\Mollie\GetIssuers;
use Mollie\Payment\Service\Mollie\MethodParameters;
use Mollie\Payment\Service\Mollie\PaymentMethods;

/**
* Class MollieConfigProvider
Expand All @@ -29,39 +30,6 @@
*/
class MollieConfigProvider implements ConfigProviderInterface
{
/**
* @var array
*/
private $methodCodes = [
'mollie_methods_applepay',
'mollie_methods_alma',
'mollie_methods_bancomatpay',
'mollie_methods_bancontact',
'mollie_methods_banktransfer',
'mollie_methods_belfius',
'mollie_methods_billie',
'mollie_methods_blik',
'mollie_methods_creditcard',
'mollie_methods_directdebit',
'mollie_methods_eps',
'mollie_methods_giftcard',
'mollie_methods_giropay',
'mollie_methods_ideal',
'mollie_methods_in3',
'mollie_methods_kbc',
'mollie_methods_klarna',
'mollie_methods_klarnapaylater',
'mollie_methods_klarnapaynow',
'mollie_methods_klarnasliceit',
'mollie_methods_mybank',
'mollie_methods_paypal',
'mollie_methods_paysafecard',
'mollie_methods_pointofsale',
'mollie_methods_przelewy24',
'mollie_methods_sofort',
'mollie_methods_twint',
'mollie_methods_voucher',
];
/**
* @var array
*/
Expand Down Expand Up @@ -141,7 +109,7 @@ public function __construct(
$this->methodParameters = $methodParameters;
$this->supportedNetworks = $supportedNetworks;

foreach ($this->methodCodes as $code) {
foreach (PaymentMethods::METHODS as $code) {
$this->methods[$code] = $this->getMethodInstance($code);
}
}
Expand Down Expand Up @@ -193,11 +161,12 @@ public function getConfig(): array
$this->mollieHelper->addTolog('error', $exception->getMessage());
}

foreach ($this->methodCodes as $code) {
foreach (PaymentMethods::METHODS as $code) {
if (empty($this->methods[$code])) {
continue;
}

$isActive = array_key_exists($code, $activeMethods);
$isAvailable = $this->methods[$code]->isActive();

$config['payment']['image'][$code] = '';
Expand All @@ -208,8 +177,9 @@ public function getConfig(): array
}

if ($isAvailable &&
$isActive &&
$mollieApi &&
in_array($code, ['mollie_methods_ideal', 'mollie_methods_kbc', 'mollie_methods_giftcard'])
in_array($code, ['mollie_methods_kbc', 'mollie_methods_giftcard'])
) {
$config = $this->getIssuers($mollieApi, $code, $config);
}
Expand Down
12 changes: 6 additions & 6 deletions Service/Magento/PaymentLinkRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ public function execute(string $orderId): PaymentLinkRedirectResult
throw new NotFoundException(__('Order not found'));
}

if ($this->isPaymentLinkExpired->execute($order)) {
if (in_array($order->getState(), [Order::STATE_PROCESSING, Order::STATE_COMPLETE])) {
return $this->paymentLinkRedirectResultFactory->create([
'redirectUrl' => null,
'isExpired' => true,
'alreadyPaid' => false,
'isExpired' => false,
'alreadyPaid' => true,
]);
}

if (in_array($order->getState(), [Order::STATE_PROCESSING, Order::STATE_COMPLETE])) {
if ($this->isPaymentLinkExpired->execute($order) || !$order->canReorder()) {
return $this->paymentLinkRedirectResultFactory->create([
'redirectUrl' => null,
'isExpired' => false,
'alreadyPaid' => true,
'isExpired' => true,
'alreadyPaid' => false,
]);
}

Expand Down
7 changes: 6 additions & 1 deletion Service/Mollie/GetMollieStatusResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public function shouldRedirectToSuccessPage(): bool
return true;
}

return in_array($status, ['pending', 'paid', 'authorized']);
return in_array($status, [
'pending',
'paid',
'authorized',
'completed', // Completed is mainly to support digital products
]);
}
}
23 changes: 10 additions & 13 deletions Service/Mollie/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ class PaymentMethods
*/
private $config;

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

/**
* @var array
*/
private $methods = [
public const METHODS = [
'mollie_methods_applepay',
'mollie_methods_alma',
'mollie_methods_bancomatpay',
Expand Down Expand Up @@ -55,12 +46,18 @@ public function __construct(
'mollie_methods_voucher',
];

public function getCodes()
public function __construct(
Config $config
) {
$this->config = $config;
}

public function getCodes(): array
{
return $this->methods;
return static::METHODS;
}

public function getCodeswithTitle()
public function getCodesWithTitle(): array
{
return array_map(function ($method) {
return [
Expand Down
Loading

0 comments on commit ca64e77

Please sign in to comment.