1

Because I want to send Notification with response error code by Payment Gateway) when transactions are isValid. And I found the Magento\Payment\Gateway\Command\GatewayCommand do the command with Payment Gateway.

below is my app\code\My\PaymentFaildNotification\Gateway\Command\GatewayCommand.php file.

public function execute(array $commandSubject)
{
    // @TODO implement exceptions catching
    $transferO = $this->transferFactory->create(
        $this->requestBuilder->build($commandSubject)
    );

    $response = $this->client->placeRequest($transferO);
    if ($this->validator !== null) {
        $result = $this->validator->validate(
            array_merge($commandSubject, ['response' => $response])
        );
        if (!$result->isValid()) {
            $this->doNotification($transferO->getBody(), $response)
            $this->processErrors($result);
        }
    }

    if ($this->handler) {
        $this->handler->handle(
            $commandSubject,
            $response
        );
    }
}

private function doNotification($request, $result)
{
    .......
}

And My app\code\My\PaymentFaildNotification\etc\di.xml is just like below:

<?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
         <preference for="Magento\Payment\Gateway\Command\GatewayCommand" 
         type="My\PaymentFaildNotification\Gateway\Command\GatewayCommand"/>
    </config>

And app\code\My\PaymentFaildNotification\etc\module.xml is just like below:

<?xml version="1.0" ?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="My_PaymentFaildNotification" setup_version="1.0.2" >
    <sequence>
        <module name="Magento_Payment"/>
    </sequence>
</module>

And app\code\My\PaymentFaildNotification\registration.php is just like below:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'My_PaymentFaildNotification',
__DIR__);

After setup:upgrade and setup:di:compile and .... It does'n work. Are there anything setting wrong ? or it can not be override with GatewayCommand ?

Thank you.

4
  • Have you checked adding log in your overrided file! Commented Dec 21, 2020 at 16:58
  • @RutveeSojitra Yes, and I run the overrided file in vendor/Magento\Payment\Gateway\Command\GatewayCommand. It's OK. Commented Dec 22, 2020 at 1:00
  • 1
    any solution for this? same case its not working for me. Commented Jan 27, 2022 at 18:54
  • Have you found any solution? Commented Jun 9, 2023 at 13:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.