You can get all the active payment method list using Magento 2 by PaymentMethodListInterface interface.
You can fetch the list of all active payment method only with the specific store by Payment title/code and name.
You just need to pass current store id in the getActiveList() method of above interface.
<?php namespace Rbj\Payment\Model; use Magento\Payment\Api\PaymentMethodListInterface; class PaymentActiveByStore { /** * @var PaymentMethodListInterface */ private $paymentMethodList; public function __construct( PaymentMethodListInterface $paymentMethodList, ) { $this->paymentMethodList = $paymentMethodList; } public function getActivePayment() { $storeId = 1; $activePaymentMethodList = $this->paymentMethodList->getActiveList($storeId); return $activePaymentMethodList; } }
You can call the above function and iterate over a loop to get all the active payment method list,
$payments = $this->getActivePayment(); foreach ($payments as $payment) { echo $payment->getCode(); echo $payment->getTitle(); }
You got the Payment method code and Payment title as the response.