I did try to add Extension attributes to Magento\Checkout\Api\Data\PaymentDetailsInterface for my custom payment module.

After setup:di:compile (it took more than two hours, is this normal??) my payment method and none of the existing OfflinePayment methods did work anymore. When placing an order in checkout I got this error message:

{"messages":{"error":[{"code":500,"message":"Fatal Error: 'Call to a member function getMethod() on null' in '...myModule\\Observer\\BeforePlaceOrderObserver.php' on line 46","trace":"Trace is not available."}]}}

It shows that my Observer class was not able to get a payment object anymore. The code below is from Magento\OfflinePayments\Observer\

      public function execute(\Magento\Framework\Event\Observer $observer)
    $payment = $observer->getEvent()->getPayment();
    $instructionMethods = [
if (in_array($payment->getMethod(), $instructionMethods)) {...

Even after rolling back my code (and compiling again) the system's behaviour is still the same. Additional information: Because I am working on a bitnami stack I do not work on the latest m2 version. Before compiling I did the trick found in that ticket to prevent from the related compiling error. As the author said there are several more errors but the compiling did finish.

Any ideas?

Update: The raising event is "sales_order_place_after" As far as I can see the getPayment()-method returns a null value. But I have no idea why.

  • Did you already flush your cache? Does it work in dev mode? Commented Mar 6, 2016 at 19:31
  • The application runs in dev mode. Yes, I have flushed the cache
    – Tenobi
    Commented Mar 6, 2016 at 19:36
  • Can you post the code related to that error? Commented Mar 6, 2016 at 19:38
  • It is in the posting. The error occurs on $payment->getMethod() as you can see in the error message
    – Tenobi
    Commented Mar 6, 2016 at 19:39
  • It is the same code snippet that is used in my module and the error occurs in both modules
    – Tenobi
    Commented Mar 6, 2016 at 19:40

1 Answer 1


Ok, the error was my fault. Someone changed the event type in events.xml so there was no payment object reachable in this event context. The correct event is


and it is used in the OfflinePaymentMethods, too. The usage of


was wrong here. Sorry for the confusion and thanks to RiccardoT for your input!

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.