🔥 Just Launched! Werra Premium Template for HyväSee it in Action

Solution to Get All Credit Card Types in Magento 2

By Sanjay JethvaUpdated on Jun 16, 2025 1 min read

Magento 2 offers a limited set of default payment methods, which may not help to offer diverse payment options. Developing a custom payment option can help you overcome this problem. 

If you opt to customize the existing credit card payment form on the Magento admin order creation, you will need to get and show all the available credit card types in Magento 2 using a code. 

Get all available Credit Card Types in Magento 2 Using Code

Integrate the below code and create the below function to get all available credit card type in Magento 2

protected $paymentConfig;

 public function __construct(
        \Magento\Payment\Model\Config $paymentConfig
    ) {
        $this->paymentConfig = $paymentConfig;

    }

    public function getCcType()
    {
        return $this->paymentConfig->getCcTypes();
    }

Here, the method getCcTypes() will return a list of credit card types available on the website. The above code will generate an array with the names of credit card types like:

[
    'VI' => 'Visa',
    'MC' => 'MasterCard',
    'AE' => 'American Express',
    ...
]

That’s it. Make your custom requirement implementation easy with this simple solution. Feel free to reach out to us if you require a custom payment extension development

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.