6

I am working on a custom payment method. I am stuck in between where one of my methods required Payment object of \Magento\Payment\Model\InfoInterface

But I am getting Magento\Sales\Model\Order\Payment\Interceptor

from order object.

How Can I get this Payment object of \Magento\Payment\Model\InfoInterface?

Thanks

1
  • Hello! Did you find the solution how to get Payment object of \Magento\Payment\Model\InfoInterface ? I have same problem. Thank you! Commented Nov 30, 2022 at 15:14

2 Answers 2

0

You can try Following if your request builder is executing:

namespace Vendor\Module\Gateway\Payment\Request; use Magento\Payment\Gateway\Request\BuilderInterface; use Magento\Payment\Gateway\Helper\SubjectReader; class Yourclass implements BuilderInterface { public function build(array $buildSubject) { $paymentDO = SubjectReader::readPayment($buildSubject); $paymentInfo = $paymentDO->getPayment() //this will give you \Magento\Payment\Model\InfoInterface } } 

You refer above as example basically you need to use $paymentDO->getPayment() following code in your class as used in above.

6
  • Can I get this payment object by order object '$this->order->getPayment()'? Commented Feb 16, 2018 at 11:16
  • I am not using request builder Commented Feb 16, 2018 at 11:23
  • Could you share you code where you want to get InfoInterface , because as per I know if you are using magento2 pattern of building payment gateway you can get you InfoInterface in both request and response by using this SubjectReader::readPayment($buildSubject) if you need some where else mention in your question. Commented Feb 16, 2018 at 11:29
  • My payment method is bit custom which is not using the magento2 Gatway. I am trying this is controller Commented Feb 16, 2018 at 11:31
  • @Charlie have you got answer? Commented Sep 12, 2018 at 14:40
0

I found an example of where an object of type \Magento\Payment\Model\InfoInterface can be found and how it is instantiated.

you may want to look at the file \Magento\Sales\Model\Order\Pdf\AbstractPdf

line $paymentInfo = $this->_paymentData->getInfoBlock($order->getPayment())->setIsSecureMode(true)->toPdf();

this line shows you how the invoice for an order is generated. This specific line extracts the payment information for the order. And the variable $order->getPayment() specifically is an object of type \Magento\Payment\Model\InfoInterface

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.