0

My authorization command is not calling even I declared in di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <!-- Payment Method Facade configuration -->
        <virtualType name="TarlanPayFacade" type="Magento\Payment\Model\Method\Adapter">
            <arguments>
                <argument name="code" xsi:type="const">\TarlanPay\TarlanPay\Model\ConfigProvider::CODE</argument>
                <argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument> 
                <argument name = "infoBlockType" xsi:type = "string">\TarlanPay\TarlanPay\Block\Info</argument>
                <argument name ="valueHandlerPool" xsi:type="object">TarlanPayValueHandlerPool</argument>
                <argument name="commandPool" xsi:type="object">TarlanPayCommandPool</argument>
            </arguments>
        </virtualType>
        <!-- Config Reader-->
        <virtualType name="TarlanPayConfig" type="Magento\Payment\Gateway\Config\Config">
            <arguments>
                <argument name="methodCode" xsi:type="const">\TarlanPay\TarlanPay\Model\ConfigProvider::CODE</argument>
            </arguments>
        </virtualType>
    <!-- Commands infrastructure -->
        <virtualType name="TarlanPayCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
            <arguments>
                <argument name="commands" xsi:type="array">
                    <item name = "authorize" xsi:type = "string">TarlanPayAuthorizeCommand</item>
                    <item name="capture" xsi:type="string">TarlanPayCaptureCommand</item>   
                </argument> 
            </arguments>
        </virtualType>
        <!-- Authorize Command-->
        <virtualType name = "TarlanPayAuthorizeCommand" type = "Magento\Payment\Gateway\Command\GatewayCommand">
            <arguments>
                <argument name = "requestBuilder" xsi:type = "object">TarlanPayAuthorizationRequest</argument>
                <argument name = "transferFactory" xsi:type = "object">TarlanPay\TarlanPay\Gateway\Http\TransferFactory</argument>
            </arguments>
        </virtualType>
        <!-- Authorization Request -->
        <virtualType name = "TarlanPayAuthorizationRequest" type = "Magento\Payment\Gateway\Request\BuilderComposite">
            <arguments>
                <argument name = "builders" xsi:type = "array">
                    <item name = "transaction" xsi:type = "string">TarlanPay\TarlanPay\Gateway\Request\AuthorizationRequest</item>
                </argument>
            </arguments>
        </virtualType>
        <type name = "TarlanPay\TarlanPay\Gateway\Request\AuthorizationRequest">
            <arguments>
                <argument name = "config" xsi:type = "object">TarlanPayConfig</argument>
            </arguments>
        </type>
         <!-- Capture command -->
        <virtualType name="TarlanPayCaptureCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
            <arguments>
                <argument name="requestBuilder" xsi:type="object">TarlanPay\TarlanPay\Gateway\Request\CaptureRequest</argument>
                <argument name = "transferFactory" xsi:type = "object">TarlanPay\TarlanPay\Gateway\Http\TransferFactory</argument>
            </arguments>
        </virtualType>
        <!-- Capture Request-->
        <type name="TarlanPay\TarlanPay\Gateway\Request\CaptureRequest">
            <arguments>
                <argument name="config" xsi:type="object">TarlanPayConfig</argument>
            </arguments>
        </type>
        <!-- ValueHandlerPool config -->
     <virtualType name="TarlanPayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
            <arguments>
                <argument name="handlers" xsi:type="array">
                    <item name="default" xsi:type="string">TarlanPayConfigValueHandler</item>
                </argument>
            </arguments>
        </virtualType>
        <virtualType name="TarlanPayConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
            <arguments>
                <argument name="configInterface" xsi:type="object">TarlanPayConfig</argument>
            </arguments>
        </virtualType>
        <type name = "TarlanPay\TarlanPay\Block\Info">
        <arguments>
            <argument name = "config" xsi:type = "object">TarlanPayConfig</argument>
        </arguments>
        </type>
    </config>

My authorization request:

<?php

    namespace TarlanPay\TarlanPay\Gateway\Request;

    use Magento\Payment\Gateway\ConfigInterface;
    use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
    use Magento\Payment\Gateway\Request\BuilderInterface;


    Class AuthorizationRequest implements BuilderInterface{

        private $config;

        public function __construct(ConfigInterface $config){

            $this->config = $config;
        }

        public function build(array $buildSubject){

            if(!isset ($buldSubject['payment']) || !$buildSubjct['payment'] instanceof PaymentDataObjectInterface){
            throw new \InvalidargumentException('Payment Data should be provided');
        }

            $payment = $buildSubjct['paymet'];
            $order = $payment->getOrder();
            $address = $order->getShippingAddress();

            return [
                'INVOICE' => $order->getOrderIncrementId(),
                'AMOUNT' => $order->getGrandTotalAmount(),
                'CURRENCY' => $order->getCurrencyCode(),
                'MERCHANT_ID' => $this->config->getValue('merchant_id', $order->getStoreId()),
                'SECRET_KEY' => $this->config->getValue('secret_key', $order->getStoreId())
            ];
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.