Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ln8711 opened this issue Jul 2, 2016 · 2 comments
Closed
Assignees
Labels
bug report Component: Payment Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@ln8711
Copy link

ln8711 commented Jul 2, 2016

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);
@ln8711 ln8711 changed the title issue with get active payment methods (getActiveMethods) issue with get active payment methods (getActiveMethods) - Mageno CE 2.1 Jul 2, 2016
@ln8711 ln8711 changed the title issue with get active payment methods (getActiveMethods) - Mageno CE 2.1 issue with get active payment methods (getActiveMethods) - Magento CE 2.1 Jul 4, 2016
@dkvashninbay
Copy link
Contributor

Created internal ticket MAGETWO-55057
Probable solution - call to MethodInterface::setId(...) will be eliminated with a high probability as it's obsolete, due to MethodInterface objects are instantiated with payment code and there is no need to set it from client code.

@alena-marchenko alena-marchenko added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 5, 2016
@alena-marchenko
Copy link

Hi @hoanglan87

Fix for MAGETWO-55057 ticket is already merged to develop branch.
Closing the issue, please feel free to reopen if the issue still reproducible for you.

mmansoor-magento pushed a commit that referenced this issue Jul 22, 2016
…getActiveMethods) - Magento CE 2.1

 - Removed id setter as necessary call
mmansoor-magento pushed a commit that referenced this issue Jul 22, 2016
…getActiveMethods) - Magento CE 2.1

 - Replaced mock of class to interface mock
magento-engcom-team pushed a commit that referenced this issue Mar 1, 2020
[Owls] Add redundant dependencies whitelist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Payment Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

4 participants