We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Sometimes we need to get payment information from orders. Today we are going to show you how to get it. When you are using custom payment methods, sometimes, you may require to get payment-related additional details from order in Magento 2.

    Here we get information using object manager

    $orderId = 100;
    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);
    
    $additionalInformation = $order->getPayment()->getAdditionalInformation();

    Here we can get information using block

    use MagentoSalesModelOrderRepository;
     
     private $orderRepository;
     
     public function __construct(OrderRepository $orderRepository) {
       $this->orderRepository = $orderRepository;
     } 
     
     public function getOrderAdditionalInfo($orderId)
     {
       $order = $this->orderRepository->get($orderId);
       $additionalInformation = $order->getPayment()->getAdditionalInformation();
       return $additionalInformation;
     }

    That’s it.

    field_5bfb909c5ccae

      Get a Free Quote