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.