After customer create order with Authorize.net, the info in Payment Information in admin view order says "Credit Card Direct Post (Authorize.net) The order was placed using USD.". How can I add type of card and last 4 digits to this block also?

  • The current implementation of Authorize.net payment method in Magento does not allow to display credit card details because it does not store any details about cards. – joni jones Jan 18 '17 at 14:29

I created custom extension to achieve this


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Authorizenet\Model\Directpost" type="MyVendor\MyModule\Model\Directpost" />


namespace MyVendor\MyModule\Model;

class Directpost extends \Magento\Authorizenet\Model\Directpost
    protected function fillPaymentByResponse(\Magento\Framework\DataObject $payment)
        $response = $this->getResponse();


<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="payment_additional_info">
            <block class="MyVendor\MyModule\Block\Payment" name="authorizenet_additional" template="MyVendor_MyModule::order/view/info/authorizenet_additional.phtml" />


<p>Last 4 digits: <?php echo $block->getCcLast4(); ?></p>
<p>CC Type: <?php echo $block->getCcType(); ?></p>
<p>Total Amount: <?php echo $this->helper('Magento\Framework\Pricing\Helper\Data')->currency($block->getAmountPaid(),true,false); ?></p>


namespace MyVendor\MyModule\Block;

class Payment extends \Magento\Sales\Block\Order\Info
    public function toHtml() {
        return $this->getOrder()->getPayment()->getMethod()=='authorizenet_directpost' ? parent::toHtml() : '';
    public function getCcLast4()
        return $this->getOrder()->getPayment()->decrypt($this->getOrder()->getPayment()->getCcLast4());
    public function getAmountPaid()
        return $this->getOrder()->getPayment()->getAmountPaid();
    public function getCcType()
        return $this->getOrder()->getPayment()->getCcType();

So I found that last digits was stored in db already, and for saving card type I needed to extend Directpost model a little. And then just retrieve all required data from order payment model

| improve this answer | |
  • 1
    Very useful module, thanks! wouldn't you mind if I will put this code on github for those who dont like cut&paste? – Viperet Aug 9 '17 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.