The default Magento 2 offers multiple payment methods which can be configured in your store to collect secure online payments from the store customers.
Or you can create payment method in Magento 2 for satisfying the custom business requirements.
However, when you are using such custom payment methods, sometimes, you may require to get payment-related additional details, for example, transaction ID, from order in Magento 2.
Even if you are using custom Magento 2 payment gateway integration extensions, you may require to get payment related additional information from order in Magento 2.
In these cases, use the method as shown below:
Method to Get Payment Related Additional Information From Order in Magento 2:
// load magento order by id using objectManager $orderId = 99; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $order = $objectManager->create('\Magento\Sales\Model\OrderRepository')->get($orderId); //get payment additional information from order $additionalInformation = $order->getPayment()->getAdditionalInformation(); // load magento order by id using block method use Magento\Sales\Model\OrderRepository; 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.
Do share the post with Magento Community via social media.
Thank you.