3

I'm trying to create plugin for Magento/Checkout/Model/PaymentInformationManagement class

When I'm placing the order, the program stops after constructor in my plugin class.

Here is /etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Model\PaymentInformationManagement">
    <plugin name="save-quote" type="Company\Newsletter\Model\Plugin\Checkout\MyPaymentInformationManagement" sortOrder="110"/>
</type>
</config>

And /Model/Plugin/Checkout/MyPaymentInformationManagement.php

<?php

namespace Company\Newsletter\Model\Plugin\Checkout;

use Magento\Quote\Model\QuoteRepository;
use Magento\Checkout\Model\PaymentInformationManagement as 
PaymentManagement;
use Magento\Checkout\Api\Data\PaymentDetailsInterface;

class MyPaymentInformationManagement
{

/**
 * @var \Magento\Quote\Model\QuoteRepository
 */
protected $_quoteRepository;

/**
 * @param QuoteRepository $quoteRepository
 */
public function __construct(QuoteRepository $quoteRepository)
{
    $this->_quoteRepository = $quoteRepository;
}

public function beforeSavePaymentInformation(PaymentManagement $subject, $cartId, PaymentDetailsInterface $paymentInformation)
{
    //some code
}
}

1 Answer 1

0

Problem lay in declaration of usage Magento\Checkout\Api\Data\PaymentDetailsInterface

and PaymentDetailsInterface $paymentInformation in method that is not Instance / missing Api connection.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.