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
hoanglan87 opened this Issue Jul 2, 2016 · 2 comments

Comments

Projects
4 participants
@hoanglan87

hoanglan87 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);

@hoanglan87 hoanglan87 changed the title from issue with get active payment methods (getActiveMethods) to issue with get active payment methods (getActiveMethods) - Mageno CE 2.1 Jul 2, 2016

@hoanglan87 hoanglan87 changed the title from issue with get active payment methods (getActiveMethods) - Mageno CE 2.1 to issue with get active payment methods (getActiveMethods) - Magento CE 2.1 Jul 4, 2016

@dkvashninbay

This comment has been minimized.

Show comment
Hide comment
@dkvashninbay

dkvashninbay Jul 5, 2016

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.

Contributor

dkvashninbay commented Jul 5, 2016

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

This comment has been minimized.

Show comment
Hide comment
@alena-marchenko

alena-marchenko Jul 21, 2016

Contributor

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.

Contributor

alena-marchenko commented Jul 21, 2016

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

MAGETWO-55057: [GITHUB #5413] issue with get active payment methods (…
…getActiveMethods) - Magento CE 2.1

 - Removed id setter as necessary call

mmansoor-magento pushed a commit that referenced this issue Jul 22, 2016

MAGETWO-55057: [GITHUB #5413] issue with get active payment methods (…
…getActiveMethods) - Magento CE 2.1

 - Replaced mock of class to interface mock

@magento-engcom-team magento-engcom-team moved this from TODO to Done in branch [2.3-develop] Sep 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment