Changing the display of Credit Card information in Magento Admin

Changing the display of Credit Card information in Magento Admin

September 4, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Changing the display of Credit Card information in Magento Admin

Securing Credit Card Information in Magento Admin

As an e-commerce developer, you understand that secure handling of credit card information is critical for your clients’ businesses and their customers’ data protection. In Magento, the system properly encrypts sensitive card details using PCI-compliant procedures like StoredCC. However, while this encryption ensures security within the database, it poses a challenge when displaying order information in the Magento Admin panel.

Understanding the Current State

When you navigate to Sales -> Orders and select an order, Magento decrypts and displays the full credit card number on the order page. This display is done correctly for typical storefront usage but can be problematic within your admin interface if not properly handled.

Your Request: Changing Credit Card Display in Admin Panel

You have requested to modify this behavior specifically at the programming level rather than through CSS modifications. The ultimate goal is to either truncate or completely suppress the display of credit card numbers on the order information page in Magento’s Admin panel.

Modifying the getPaymentHTML() Function

To achieve this, you’ll need to override the getPaymentHTML() function found within your payment module’s model file. This function is responsible for generating the HTML output containing the credit card details displayed on the admin order view page.

Here are the steps to modify it:

  1. Navigate to your custom payment module located in app/code/[Vendor]/[Module]/Model/Payment/.

  2. Open the getPaymentHTML() function in the appropriate model file (usually named Model_Payment.php).

  3. Inside this function, locate the section where the credit card number is being prepared for display. In most cases, you’ll find it inside a loop that iterates through the payment information.

  4. You can either truncate the number to display only the last few digits or suppress its display entirely based on your specific requirements.

Example: Truncating Credit Card Number

foreach ($paymentInfo as $info) {
    $html .= '<p><strong>' . Mage::helper('payment')->__($this->getMethodTitle()) .
             ':</strong> ' . Mage::helper('core')->escapeHtml($info['cc_type']) . ' ' .
             '****-****-****-' . substr($info['cc_number'], -4) . '</p>';
}

In this example, I’ve modified the credit card number by truncating it to display only the last four digits after the asterisks using substr($info['cc_number'], -4).

Example: Suppressing Credit Card Number

foreach ($paymentInfo as $info) {
    $html .= '<p><strong>' . Mage::helper('payment')->__($this->getMethodTitle()) .
             ':</strong> [Credit Card Information]</p>';
}

In this case, I’ve completely suppressed the credit card number display by replacing it with a static text string.

Ensuring Proper Override

To ensure your changes are properly overridden and applied, make sure you follow Magento’s best practices for extending core functionality:

  • Use Magento’s module system to create your custom payment module.
  • Implement method rewrites or plugins as needed.
  • Follow the version control guidelines to avoid conflicts with future Magento updates.

Conclusion: Securing Credit Card Display in Admin Panel

By overriding and modifying the getPaymentHTML() function within your custom payment model, you can effectively change or suppress the display of credit card information on Magento’s order view page in the admin panel. This approach ensures a secure and PCI-compliant handling of sensitive customer data throughout your e-commerce platform.

Remember to thoroughly test your changes in a development environment before deploying them to your live production site. For more detailed guides on Magento module development, consider exploring our comprehensive resources at Laravel Company.

By implementing these modifications, you’ll enhance the security of your e-commerce platform and provide an improved user experience for admin users while maintaining customer data privacy standards.

Database Security Extensions Themes

Our network