Bounty Ended with 200 reputation awarded by Community
2 added 3015 characters in body
source | link

if you dont want to change in the core file than you need to override that file follow the below code

Go to Vendor/Extension/etc/di.xml And Write below code into di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Payment\Helper\Data" type="Vendor\Extension\Helper\Data"/>
</config>

Next Step is to Create Data.php file at Vendor\Extension\Helper\Data.php

<?php
namespace Vendor\Extension\Helper;

use Magento\Payment\Helper\Data as MainHelper;

class Data extends MainHelper
{
    public function getPaymentMethodList($sorted = true, $asLabelValue = false, $withGroups = false, $store = null)
    {
        $methods = [];
        $groups = [];
        $groupRelations = [];


        foreach ($this->getPaymentMethods() as $code => $data) {

            $data['active'] = 1;

            if (!empty($data['active'])) {
                $storedTitle = $this->getMethodInstance($code)->getConfigData('title', $store);
                if (isset($storedTitle)) {
                    $methods[$code] = $storedTitle;
                } elseif (isset($data['title'])) {
                    $methods[$code] = $data['title'];
                }
            }
            if ($asLabelValue && $withGroups && isset($data['group'])) {
                $groupRelations[$code] = $data['group'];
            }
        }
        if ($asLabelValue && $withGroups) {
            $groups = $this->_paymentConfig->getGroups();
            foreach ($groups as $code => $title) {
                $methods[$code] = $title;
            }
        }
        if ($sorted) {
            asort($methods);
        }
        if ($asLabelValue) {
            $labelValues = [];
            foreach ($methods as $code => $title) {
                $labelValues[$code] = [];
            }
            foreach ($methods as $code => $title) {
                if (isset($groups[$code])) {
                    $labelValues[$code]['label'] = $title;
                    if (!isset($labelValues[$code]['value'])) {
                        $labelValues[$code]['value'] = null;
                    }
                } elseif (isset($groupRelations[$code])) {
                    unset($labelValues[$code]);
                    $labelValues[$groupRelations[$code]]['value'][$code] = ['value' => $code, 'label' => $title];
                } else {
                    $labelValues[$code] = ['value' => $code, 'label' => $title];
                }
            }

            return $labelValues;
        }


        return $methods;
    }
}

if you dont want to change in the core file than you need to override that file follow the below code

Go to Vendor/Extension/etc/di.xml And Write below code into di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Payment\Helper\Data" type="Vendor\Extension\Helper\Data"/>
</config>

Next Step is to Create Data.php file at Vendor\Extension\Helper\Data.php

<?php
namespace Vendor\Extension\Helper;

use Magento\Payment\Helper\Data as MainHelper;

class Data extends MainHelper
{
    public function getPaymentMethodList($sorted = true, $asLabelValue = false, $withGroups = false, $store = null)
    {
        $methods = [];
        $groups = [];
        $groupRelations = [];


        foreach ($this->getPaymentMethods() as $code => $data) {

            $data['active'] = 1;

            if (!empty($data['active'])) {
                $storedTitle = $this->getMethodInstance($code)->getConfigData('title', $store);
                if (isset($storedTitle)) {
                    $methods[$code] = $storedTitle;
                } elseif (isset($data['title'])) {
                    $methods[$code] = $data['title'];
                }
            }
            if ($asLabelValue && $withGroups && isset($data['group'])) {
                $groupRelations[$code] = $data['group'];
            }
        }
        if ($asLabelValue && $withGroups) {
            $groups = $this->_paymentConfig->getGroups();
            foreach ($groups as $code => $title) {
                $methods[$code] = $title;
            }
        }
        if ($sorted) {
            asort($methods);
        }
        if ($asLabelValue) {
            $labelValues = [];
            foreach ($methods as $code => $title) {
                $labelValues[$code] = [];
            }
            foreach ($methods as $code => $title) {
                if (isset($groups[$code])) {
                    $labelValues[$code]['label'] = $title;
                    if (!isset($labelValues[$code]['value'])) {
                        $labelValues[$code]['value'] = null;
                    }
                } elseif (isset($groupRelations[$code])) {
                    unset($labelValues[$code]);
                    $labelValues[$groupRelations[$code]]['value'][$code] = ['value' => $code, 'label' => $title];
                } else {
                    $labelValues[$code] = ['value' => $code, 'label' => $title];
                }
            }

            return $labelValues;
        }


        return $methods;
    }
}
1
source | link

open file vendor/magento/module-payment/Helper/data.php

at line number 268 put this line

$data['active'] = 1;