Skip to content

Third Party Payment Method Are not Loading in admin Default Payment Method Section #5

@wcladesh

Description

@wcladesh

I have found a bug in the admin section that all active payment methods are not loading, it loads only default Magento 2 enabled Payment Methods.

After overriding and edit file Model/System/Config/Source/PaymentMethods.php and write below code

/**
* @var ScopeConfigInterface
/
protected $_appConfigScopeConfigInterface;
/
*
* @var Config
*/
protected $_paymentModelConfig;

/**
 * @param ScopeConfigInterface $appConfigScopeConfigInterface
 * @param Config               $paymentModelConfig
 */
public function __construct(
    ScopeConfigInterface $appConfigScopeConfigInterface,
    Config $paymentModelConfig
) {

    $this->_appConfigScopeConfigInterface = $appConfigScopeConfigInterface;
    $this->_paymentModelConfig = $paymentModelConfig;
}

public function toOptionArray()
{
    $payments = $this->_paymentModelConfig->getActiveMethods();
    
    $methods = array();
    $methods = [['label' => __('-- Please select --'), 'value' => '']];
    foreach ($payments as $paymentCode => $paymentModel) {
        $paymentTitle = $this->_appConfigScopeConfigInterface
            ->getValue('payment/'.$paymentCode.'/title');
        $methods[$paymentCode] = array(
            'label' => $paymentTitle,
            'value' => $paymentCode
        );
    }
    return $methods;
}

Please resolve issue and upgrade your module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions