I'm trying to create payment module that rewrite method savePaymentInformationAndPlaceOrder in model \Magento\Checkout\Model\PaymentInformationManagement.

Here is snippet code from my own module in file : /app/code/Mine/Directpaym/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">
    <preference for="Magento\Checkout\Model\PaymentInformationManagement" type="Mine\Directpaym\Model\DirectpaymPaymentInformationManagement" />

Model /app/code/Mine/Directpaym/Model/DirectpaymPaymentInformationManagement.php:

namespace Mine\Directpaym\Model;

use Magento\Sales\Model\Order;

class DirectpaymPaymentInformationManagement extends \Magento\Checkout\Model\PaymentInformationManagement
     * {@inheritDoc}
    public function savePaymentInformationAndPlaceOrder(
        \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
        \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
    ) {
            // this method is not  called
            $this->savePaymentInformation($cartId, $paymentMethod, $billingAddress);
            return $this->cartManagement->placeOrder($cartId);

I managed to call my own method in Magento 2 community edition, but in Magento 2 Enterprise it won't work.

I already tried compile, flush cache, and static content deploy as well, still won't work.

Is there specific things I miss here?

  • Did you get your solution or still looking for this? – Dhiren Vasoya Nov 22 '16 at 10:08

You need to move you di.xml file from etc folder




So it called your function and working fine.

Your Answer

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

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