MultiSafepay / magento2-core

Provides core functionalities
Open Software License 3.0
2 stars 10 forks source link

Add can_fetch_transaction_info to payment methods #7

Closed thlassche closed 3 years ago

thlassche commented 3 years ago

This enables the 'Fetch' button in the Magento admin transaction overview.

Seems to work perfectly fine, but the capability was just not defined.

Screenshot 2021-09-14 at 10 39 43
vinodsowdagar commented 3 years ago

Hi @thlassche ,

Thank you for the PR, we will look into reviewing this as soon as possible.

vinodsowdagar commented 3 years ago

Hi @thlassche ,

After an extensive investigation, we came to the following conclusion:

When the button is clicked, the following function is being called:

In magento-payment/Model/Method/Adapter:

    /**
     * @inheritdoc
     */
    public function fetchTransactionInfo(InfoInterface $payment, $transactionId)
    {
        return $this->executeCommand(
            'fetch_transaction_information',
            ['payment' => $payment, 'transactionId' => $transactionId]
        );
    }

It tries to execute the 'fetch_transaction_information' command. If we look at the commands that we have implemented in the MultiSafepay magento2-core module di.xml:

    <!-- MultiSafepay Commands infrastructure -->
    <virtualType name="MultiSafepayCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="initialize" xsi:type="string">MultiSafepayInitializeCommand</item>
                <item name="refund" xsi:type="string">MultiSafepayRefundCommand</item>
            </argument>
        </arguments>
    </virtualType>
  1. We see that the 'fetch_transaction_information' command is not implemented. So executing the command would actually not fetch the transaction. This is something that we would have to implement alongside the button.

Therefore, i have created a backlog task to actually fetch the transaction from MultiSafepay and add more information in the Transaction Details about the transaction itself (e.g. transaction type, transaction status, order status, recurring yes/no).

I will close this PR and implement the button when we actually have a command for it as well. If i missed something, please explain and reopen.