-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #502 from mollie/release/2.8.0
Release/2.8.0
- Loading branch information
Showing
19 changed files
with
515 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Model\Adminhtml\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Mollie\Payment\Config; | ||
use Mollie\Payment\Service\Mollie\PaymentMethods; | ||
|
||
class EnabledMolliePaymentMethod implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var PaymentMethods | ||
*/ | ||
private $methods; | ||
|
||
public function __construct( | ||
Config $config, | ||
PaymentMethods $methods | ||
) { | ||
$this->methods = $methods; | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return array_filter($this->methods->getCodeswithTitle(), function ($method) { | ||
return $this->config->isMethodActive($method['value']); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...orRequestedQtyCondition/IsSalableWithReservationsCondition/DisableCheckForAdminOrders.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Plugin\InventorySales\Model\IsProductSalableForRequestedQtyCondition\IsSalableWithReservationsCondition; | ||
|
||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\InventorySalesApi\Api\Data\ProductSalableResultInterface; | ||
|
||
class DisableCheckForAdminOrders | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $disabled = false; | ||
|
||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
private $objectManager; | ||
|
||
public function __construct( | ||
ObjectManagerInterface $objectManager | ||
) { | ||
$this->objectManager = $objectManager; | ||
} | ||
|
||
/** | ||
* This method is only called from the `\Mollie\Payment\Service\Order\Reorder::recreate` method, to prevent | ||
* any errors about no stock being available. That method cancels 1 order and recreates another so in that | ||
* case it's valid to not check the stock.The objectmanager here is being used as not everyone has the | ||
* `Magento\InventorySalesApi` module available. | ||
* | ||
* @return void | ||
*/ | ||
public function disable(): void | ||
{ | ||
$this->disabled = true; | ||
} | ||
|
||
public function aroundExecute($subject, $proceed, ...$arguments) | ||
{ | ||
if ($this->disabled) { | ||
return $this->objectManager->create(ProductSalableResultInterface::class, ['errors' => []]); | ||
} | ||
|
||
return $proceed(...$arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Service\Order\Lines\Generator; | ||
|
||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mollie\Payment\Helper\General; | ||
|
||
class AheadworksAddFreeGift implements GeneratorInterface | ||
{ | ||
/** | ||
* @var General | ||
*/ | ||
private $mollieHelper; | ||
|
||
public function __construct( | ||
General $mollieHelper | ||
) { | ||
$this->mollieHelper = $mollieHelper; | ||
} | ||
|
||
public function process(OrderInterface $order, array $orderLines): array | ||
{ | ||
$discount = 0; | ||
foreach ($order->getItems() as $item) { | ||
$discount += abs($item->getAwAfptcAmount()); | ||
} | ||
|
||
if (!$discount) { | ||
return $orderLines; | ||
} | ||
|
||
$forceBaseCurrency = (bool)$this->mollieHelper->useBaseCurrency($order->getStoreId()); | ||
$currency = $forceBaseCurrency ? $order->getBaseCurrencyCode() : $order->getOrderCurrencyCode(); | ||
|
||
$orderLines[] = [ | ||
'type' => 'surcharge', | ||
'name' => 'Aheadworks Add Free Gift', | ||
'quantity' => 1, | ||
'unitPrice' => $this->mollieHelper->getAmountArray($currency, -$discount), | ||
'totalAmount' => $this->mollieHelper->getAmountArray($currency, -$discount), | ||
'vatRate' => 0, | ||
'vatAmount' => $this->mollieHelper->getAmountArray($currency, 0.0), | ||
]; | ||
|
||
return $orderLines; | ||
} | ||
} |
Oops, something went wrong.