Skip to content

sales by payment type reports display in dashboard in magento 2

Block->

<?php
namespace Block;


use MagentoPaymentApiPaymentMethodListInterface;

class AllPayment extends MagentoFrameworkViewElementTemplate
{
    protected $_paymentConfig;
protected $_scopeConfigInterface;
 
public function __construct(
 MagentoBackendBlockTemplateContext $context,
 MagentoPaymentModelConfig $paymentConfig,
 MagentoFrameworkAppConfigScopeConfigInterface $scopeConfigInterface,
 array $data = []
) 
{
 $this->_paymentConfig = $paymentConfig;
 $this->_scopeConfigInterface = $scopeConfigInterface;
 parent::__construct($context, $data);
}
 
public function getAllActivePaymentMethods() {
 $activePaymentMethods = $this->_paymentConfig->getActiveMethods();
 $activeMethods = array();
 if ($activePaymentMethods && count($activePaymentMethods) > 0) {
 foreach ($activePaymentMethods as $methodCode => $paymentModel) {
 $methodTitle = $this->_scopeConfigInterface->getValue('payment/' . $methodCode . '/title');
 $activeMethods[$methodCode] = array(
 'label' => $methodTitle,
 'value' => $methodCode
 );
 }
 }
 return $activeMethods;
}
}




phtml->

<?php
echo "<pre>";
print_r($allActivePaymentMethods);
echo "</pre>";

?>