Skip to content

Commit

Permalink
Merge pull request #379 from mollie/1.25.1
Browse files Browse the repository at this point in the history
1.25.1
  • Loading branch information
Marvin-Magmodules authored Apr 13, 2021
2 parents fdfe97e + 8cce4fc commit 3f5b7bb
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 644 deletions.
37 changes: 14 additions & 23 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Mollie\Payment;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Module\Manager;
use Magento\Payment\Model\MethodInterface;
use Magento\Store\Model\ScopeInterface;
use Mollie\Payment\Logger\MollieLogger;
Expand All @@ -30,8 +31,6 @@ class Config
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';
const GENERAL_MULTISHIPPING_ENABLED = 'payment/mollie_general/multishipping_enabled';
const GENERAL_MULTISHIPPING_DESCRIPTION = 'payment/mollie_general/multishipping_description';
const GENERAL_ORDER_STATUS_PENDING = 'payment/mollie_general/order_status_pending';
const GENERAL_PROFILEID = 'payment/mollie_general/profileid';
const GENERAL_SECOND_CHANCE_EMAIL_TEMPLATE = 'payment/mollie_general/second_chance_email_template';
Expand Down Expand Up @@ -71,12 +70,19 @@ class Config
*/
private $logger;

/**
* @var Manager
*/
private $moduleManager;

public function __construct(
ScopeConfigInterface $config,
MollieLogger $logger
MollieLogger $logger,
Manager $moduleManager
) {
$this->config = $config;
$this->logger = $logger;
$this->moduleManager = $moduleManager;
}

/**
Expand Down Expand Up @@ -544,26 +550,6 @@ public function customRedirectUrl($storeId = null, $scope = ScopeInterface::SCOP
return $this->getPath(static::GENERAL_CUSTOM_REDIRECT_URL, $storeId, $scope);
}

/**
* @param null|int|string $storeId
* @param string $scope
* @return bool
*/
public function isMultishippingEnabled($storeId = null, $scope = ScopeInterface::SCOPE_STORE): bool
{
return $this->isSetFlag(static::GENERAL_MULTISHIPPING_ENABLED, $storeId, $scope);
}

/**
* @param null|int|string $storeId
* @param string $scope
* @return string|null
*/
public function getMultishippingDescription($storeId = null, $scope = ScopeInterface::SCOPE_STORE)
{
return $this->getPath(static::GENERAL_MULTISHIPPING_DESCRIPTION, $storeId, $scope);
}

/**
* @see \Mollie\Payment\Model\Adminhtml\Source\Locale for possible values
* @param null|int|string $storeId
Expand All @@ -574,6 +560,11 @@ public function getLocale($storeId = null)
return $this->getPath(static::GENERAL_LOCALE, $storeId);
}

public function isMultishippingEnabled(): bool
{
return $this->moduleManager->isEnabled('Mollie_Multishipping');
}

/**
* @param $method
* @return string
Expand Down
30 changes: 16 additions & 14 deletions Controller/Checkout/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\Payment\Controller\Checkout;

use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Sales\Api\OrderRepositoryInterface;
use Mollie\Payment\Model\Mollie as MollieModel;
Expand All @@ -14,7 +15,6 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Session;
use Mollie\Payment\Multishipping\CheckoutRedirect;

/**
* Class Process
Expand Down Expand Up @@ -42,14 +42,14 @@ class Process extends Action
protected $mollieHelper;

/**
* @var CheckoutRedirect
* @var OrderRepositoryInterface
*/
private $multishippingRedirect;
private $orderRepository;

/**
* @var OrderRepositoryInterface
* @var ManagerInterface
*/
private $orderRepository;
private $eventManager;

/**
* Process constructor.
Expand All @@ -59,7 +59,6 @@ class Process extends Action
* @param PaymentHelper $paymentHelper
* @param MollieModel $mollieModel
* @param MollieHelper $mollieHelper
* @param CheckoutRedirect $checkoutRedirect
* @param OrderRepositoryInterface $orderRepository
*/
public function __construct(
Expand All @@ -68,15 +67,15 @@ public function __construct(
PaymentHelper $paymentHelper,
MollieModel $mollieModel,
MollieHelper $mollieHelper,
CheckoutRedirect $checkoutRedirect,
OrderRepositoryInterface $orderRepository
OrderRepositoryInterface $orderRepository,
ManagerInterface $eventManager
) {
$this->checkoutSession = $checkoutSession;
$this->paymentHelper = $paymentHelper;
$this->mollieModel = $mollieModel;
$this->mollieHelper = $mollieHelper;
$this->multishippingRedirect = $checkoutRedirect;
$this->orderRepository = $orderRepository;
$this->eventManager = $eventManager;
parent::__construct($context);
}

Expand Down Expand Up @@ -109,11 +108,14 @@ public function execute()
if (!empty($result['success'])) {
try {
$this->checkoutSession->start();
if (count($orderIds) > 1) {
$this->multishippingRedirect->redirect();
} else {
$this->_redirect('checkout/onepage/success?utm_nooverride=1');
}

$this->_redirect('checkout/onepage/success?utm_nooverride=1');

$this->eventManager->dispatch('mollie_checkout_success_redirect', [
'order_ids' => $orderIds,
'request' => $this->getRequest(),
'response' => $this->getResponse(),
]);
} catch (\Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
$this->messageManager->addErrorMessage(__('Something went wrong.'));
Expand Down
2 changes: 1 addition & 1 deletion Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
return false;
}

if ($quote->getIsMultiShipping() && !$this->config->isMultishippingEnabled($quote->getStoreId())) {
if ($quote->getIsMultiShipping() && !$this->config->isMultishippingEnabled()) {
return false;
}

Expand Down
53 changes: 0 additions & 53 deletions Multishipping/CheckoutRedirect.php

This file was deleted.

31 changes: 0 additions & 31 deletions Multishipping/CheckoutUrl.php

This file was deleted.

Loading

0 comments on commit 3f5b7bb

Please sign in to comment.