How to Get Payment Related Additional Information From Order in Magento 2
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
// 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; } |
Any doubts in the above solution? Feel free to mention them in the Comments section below.
I’ll be happy to help.
Do share the post with Magento Community via social media.
Thank you.
Jignesh Parmar
An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.
Prev
How to Create Barcode and Add it in Magento 2 Invoice PDF
Solved: Product Video Not Working in Magento 2
Next