How can show BANK TRANSFER payments method to specific customer(s), I added customer attribute to the payment method. then if BANK TRANSFER is yes I want to display it to customer. so how can I do it?

2 Answers 2


I can suggest creating a module that will be responsible for displaying the payment methods by customer group.

E.g. Enable all payment methods and select visibility of each payment method as per customer group.

That way, all payment methods are activated but are only visible to specified customer groups.

  • thanks for the idea, but they have a custom field, we have to check it and show the method.
    – Lasantha
    Commented Feb 23, 2018 at 6:30

Finally I have written a module for solve it, this is a mix of related stack overflow answers. Thanks all who wrote valuable answers. This works for me. anyone can improve this, thanks

// First create a module 

// add an event \app\code\Vender\SetBanktranfer\etc

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
 <event name="payment_method_is_active">
    <observer name="Vender_SetBanktranfer_EabledPgByCustomerattr" instance="Vender\SetBanktranfer\Observer\EabledPgByCustomerattr" />

// My observer is EabledPgByCustomerattr - \app\code\Vender\SetBanktranfer\Observer
namespace Vender\SetBanktranfer\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\App\ObjectManager;
class EabledPgByCustomerattr implements ObserverInterface
    public function __construct(\Psr\Log\LoggerInterface $logger)
        $this->_logger = $logger;
     * @param \Magento\Framework\Event\Observer $observer
     * @return void
    public function execute(\Magento\Framework\Event\Observer $observer)
        $result          = $observer->getEvent()->getResult();
        $method_instance = $observer->getEvent()->getMethodInstance();
        $quote           = $observer->getEvent()->getQuote();
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $customerSession = $objectManager->get('Magento\Customer\Model\Session');   
        $customerObj = $objectManager->create('Magento\Customer\Model\Customer')->load($customerSession->getCustomerId());      
        $approvedCredit = $customerObj->getData('approved_for_credit_acc');

                if ($method_instance->getCode() == 'banktransfer') {
                    if(($customerSession->isLoggedIn()) && ($approvedCredit == 1)) {
                        $result->setData('is_available', true);
                        $result->setData('is_available', false);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.