Created
February 4, 2020 15:03
-
-
Save MintayRibkins/b561f0a8bbeeb0571d6200aba59fe02b to your computer and use it in GitHub Desktop.
PaymentModulePart1Example
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
<?php declare(strict_types=1); | |
namespace Hrytsenko\PluginExample\Plugin; | |
use Exception; | |
use Magento\Customer\Model\SessionFactory; | |
use Magento\Payment\Api\PaymentMethodListInterface; | |
class PaymentFilterExamplePlugin | |
{ | |
/** | |
* @var SessionFactory | |
*/ | |
private $_session; | |
public function __construct(SessionFactory $session) | |
{ | |
$this->_session = $session; | |
} | |
public function beforeGetList(PaymentMethodListInterface $list) | |
{ | |
$session = $this->_session->create(); | |
if ($session->isLoggedIn()) { | |
try { | |
return true; | |
} catch (Exception $e) { | |
$e->getMessage(); | |
} | |
} else { | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment