Skip to content

Commit

Permalink
Payment limit
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo committed Jan 12, 2024
1 parent 8e30bc0 commit 3be9b4b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Model/MethodListPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Magento\Payment\Helper\Data;
use Magento\Payment\Model\MethodInterface;
use Magento\Payment\Model\MethodList;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use tpaycom\magento2basic\Api\TpayInterface;
Expand All @@ -27,19 +28,31 @@ class MethodListPlugin
/** @var StoreManagerInterface */
private $storeManager;

public function __construct(Data $data, ScopeConfigInterface $scopeConfig, OnsiteChannels $onsiteChannels, StoreManagerInterface $storeManager)
/** @var Tpay */
private $tpay;

/** @var CartInterface */
private $cartInterface;

public function __construct(Data $data, ScopeConfigInterface $scopeConfig, OnsiteChannels $onsiteChannels, StoreManagerInterface $storeManager, Tpay $tpay, CartInterface $cartInterface)
{
$this->data = $data;
$this->scopeConfig = $scopeConfig;
$this->onsiteChannels = $onsiteChannels;
$this->storeManager = $storeManager;
$this->tpay = $tpay;
$this->cartInterface = $cartInterface;
}

public function afterGetAvailableMethods(MethodList $compiled, $result)
{
$onsiteChannels = $this->scopeConfig->getValue(self::CONFIG_PATH, ScopeInterface::SCOPE_STORE);
$channels = $onsiteChannels ? explode(',', $onsiteChannels) : [];

if (!$this->tpay->isAvailable($this->cartInterface)) {
return $result;
}

$result[] = $this->getMethodInstance('tpay.com - Płatność kartą', 'tpaycom_magento2basic_cards');
$result = $this->filterResult($result);

Expand Down

0 comments on commit 3be9b4b

Please sign in to comment.