Skip to content

Instantly share code, notes, and snippets.

@MintayRibkins
Created February 4, 2020 15:03
Show Gist options
  • Save MintayRibkins/b561f0a8bbeeb0571d6200aba59fe02b to your computer and use it in GitHub Desktop.
Save MintayRibkins/b561f0a8bbeeb0571d6200aba59fe02b to your computer and use it in GitHub Desktop.
PaymentModulePart1Example
<?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