Skip to content

issue with get active payment methods (getActiveMethods) - Magento CE 2.1 #5413

Closed
@ln8711

Description

@ln8711

Steps to reproduce

  1. Enable Braintree
  2. run the functions getActiveMethods from vendor/magento/module-payment/Model/Config.php in somewhere

Expected result

  1. Show list of active payment methods

Actual result

  1. Exception Call to undefined method Magento\Payment\Model\Method\Adapter::setId() in vendor/magento/module-payment/Model/Config.php on line 98

when $data['model'] is BraintreeFacade

$methodModel = $this->_paymentMethodFactory->create($data['model']);
$methodModel->setId($code);

The factory can't create the model and then the following setId fails

Example code (put in magento/test/test.php):

<?php

require '../app/bootstrap.php';

class TestApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface
{
    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Payment\Model\Config $paymentConfig,
        \Magento\Framework\App\Response\Http $response,
        \Magento\Framework\App\ResourceConnection $resource
    ) {
        $this->_objectManager = $objectManager;
        $this->_paymentConfig = $paymentConfig;
        $this->_response = $response;
        $this->_resource = $resource;
    }

    public function launch()
    {
        $state = $this->_objectManager->get('Magento\Framework\App\State');
        $state->setAreaCode('adminhtml');

        $payments = $this->_paymentConfig->getActiveMethods();
        print_r($payments);

        return $this->_response;
    }

    public function catchException(Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception)
    {
        print_r($exception->getTraceAsString());

        return false;
    }
}

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('TestApp');

error_reporting(E_ALL);
ini_set("display_error", 1);

$bootstrap->run($app);

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions