Question

I'm trying to modify the payment block on the order detail page in backend. Therefore I've created an observer which is listening to following event:

payment_info_block_prepare_specific_information

Now, when I'm trying to get the payment code with

$payment = $observer->getEvent()->getPayment();
$paymentmethod = $payment->getMethodInstance()->getCode();

I do get following error for credit card payments (Authorize.net) only:

PHP Fatal error:  Call to a member function getCode()

Orders placed by using PayPal Express Checkout work though. Do I miss something? I appreciate any help.

Magento ver. 1.14.2.4

Was it helpful?

Solution

There's a shorter and more direct way to the data you want. The method code is stored on the payment info instance (sales_flat_order_payment) as column method.

That means:

$payment = $observer->getEvent()->getPayment();
$paymentmethod = $payment->getMethod();

That should give you the payment method code (as a string) in $paymentmethod.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top