Open t-heuser opened 3 years ago
Hi @oneserv-heuser. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
I can confirm that this issue exists, but not on an vanilla instance because of the nature of the problem.
Hi @engcom-Echo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
I reported this issue before It was closed with no solution: https://github.com/magento/magento2/issues/30211
@JeffersonTeixeira The classical stale-bot treatment
How did you fix it? Did you use the fix @ksenia-zlotin provided?
For anyone stumbling across this, here is a temporary solution:
<?php
declare(strict_types=1);
namespace Oneserv\B2BInvoice\Model\Method;
use Magento\Framework\App\Area;
use Magento\Framework\App\State;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Gateway\Command\CommandManagerInterface;
use Magento\Payment\Gateway\Command\CommandPoolInterface;
use Magento\Payment\Gateway\Config\ValueHandlerPoolInterface;
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
use Magento\Payment\Gateway\Validator\ValidatorPoolInterface;
use Magento\Payment\Model\Method\Adapter;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Psr\Log\LoggerInterface;
/**
* Class B2BInvoice
*/
class B2BInvoice extends Adapter
{
private State $state;
/**
* B2BInvoice constructor.
*
* @param ManagerInterface $eventManager
* @param ValueHandlerPoolInterface $valueHandlerPool
* @param PaymentDataObjectFactory $paymentDataObjectFactory
* @param string $code
* @param string $formBlockType
* @param string $infoBlockType
* @param State $state
* @param CommandPoolInterface|null $commandPool
* @param ValidatorPoolInterface|null $validatorPool
* @param CommandManagerInterface|null $commandExecutor
* @param LoggerInterface|null $logger
*/
public function __construct(
ManagerInterface $eventManager,
ValueHandlerPoolInterface $valueHandlerPool,
PaymentDataObjectFactory $paymentDataObjectFactory,
string $code,
string $formBlockType,
string $infoBlockType,
State $state,
CommandPoolInterface $commandPool = null,
ValidatorPoolInterface $validatorPool = null,
CommandManagerInterface $commandExecutor = null,
LoggerInterface $logger = null
) {
parent::__construct(
$eventManager,
$valueHandlerPool,
$paymentDataObjectFactory,
$code,
$formBlockType,
$infoBlockType,
$commandPool,
$validatorPool,
$commandExecutor,
$logger
);
$this->state = $state;
}
/**
* @inheritdoc
* This is a temporary workaround for https://github.com/magento/magento2/issues/33869.
* It sets the info instance before the method gets executed. Otherwise, the validator doesn't get called
* correctly.
*/
public function isAvailable(CartInterface $quote = null)
{
if ($quote === null) {
return parent::isAvailable($quote);
}
/** @var Quote $quote */
/*
* This is needed to avoid issues when creating a new order via adminhtml. There is an error as the quote has
* empty data and somewhere deep in magento it causes an issue.
*/
try {
if (
$this->state->getAreaCode() === Area::AREA_ADMINHTML &&
$quote->getDataByKey(Quote::KEY_STORE_ID) === null
) {
return parent::isAvailable($quote);
}
} catch (LocalizedException $exception) {
return parent::isAvailable($quote);
}
$this->setInfoInstance($quote->getPayment());
return parent::isAvailable($quote);
}
}
Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @oneserv-heuser,
Thank you for reporting the issue. Can you please provide more detailed 'Steps to reproduce' so that I can try to reproduce it ? If you can provide graphql steps to get the issue result, that would be helpful as well.
Also please update below information:
Hi @engcom-Lima, I've created an example module for this problem. You can find it here: https://github.com/oneserv-heuser/magento2-33869. I've also added detailed steps to reproduce this issue there and also implemented a workaround for this bug.
Probably this is not an issue, but the way checks for Payment Method need to be added is bit different?
The checks of Payment Method is also handled using the interface
Magento\Payment\Model\Checks\SpecificationInterface
and Magento\Payment\Model\Checks\SpecificationFactory
So we need to add a custom mapping and pass this as an argument in di.xml
So something like below
<type name="Magento\Payment\Model\Checks\SpecificationFactory">
<arguments>
<argument name="mapping" xsi:type="array">
<item name="customcheck" xsi:type="object">Vendor\Module\Model\Checks\CustomCheck</item>
</argument>
</arguments>
</type>
Our custom check class should implement Magento\Payment\Model\Checks\SpecificationInterface
Hi @engcom-Lima, I've created an example module for this problem. You can find it here: https://github.com/oneserv-heuser/magento2-33869. I've also added detailed steps to reproduce this issue there and also implemented a workaround for this bug.
Hey @engcom-Lima Can you please have a look at my example and try to reproduce the issue?
Hi @oneserv-heuser ,
Thank you for providing the custom module and detailed explanation to the problem.
I have checked with my own created custom payment method and also with @oneserv’s custom module and it seems the issue is there as Payment method is showing after making its validity false in Validator pool. Probable cause being getInfoInstance() being null so Validator pool not getting called although it is defined in di.xml as per DevDocs.
Based on it, I am confirming this issue so that the core team can do further analysis and work on a permanent solution to this problem.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6081 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Having the same issue.... after roughly two years. Thanks for the workaround though.
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Cause of the problem
The cause of the problem is that Adapter::isAvailable() gets called from MethodList::getAvailableMethods(). The Adapter::isAvailable() method then tries to get the infoInstance as seen on line 290. If it's null it will not execute the availability validator from the validatorPool which would return false. The infoInstance is ALWAYS null in this case as the method instance gets freshly created from it's factory. The MethodList::getAvailableMethods() sets the infoInstance AFTER it calls the Adapter::isAvailable() method. So there is no way the validator gets called when using the new Payment Provider Gateway.
I guess this issue was never found as all of magentos payment methods are using the deprecated AbstractMethod class. I think this should be fixed asap as the method MethodList::getAvailableMethods() MUST work for all payment methods, especially if they're implemented the way they should be and not with deprecated classes.
Possible workarounds
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.