Magento 2 Change Sequence of Credit Card Type

One of our client asked to update the sort order of credit card type of Magento 2 custom payment module. The reason is, they want to display a specific credit card logo in the first position, like display VISA logo at first. If you are looking to do the same then this blog post by Dhairvi Solutions helps you.

Assume you want to display VISA in the first position on Magento 2 checkout page.

Magento 2 Credit Card Type

Follow the below steps to change the sequence of credit card types in the Magento 2
Step 1: Copy magento default payment.xml file from \vendor\magento\module-payment\etc\
Step 2: Paste copied payment.xml file to your custom module.
E.g., /app/code/Dhairvi/Demo/etc/payment.xml
Step 3: Update the “order” attribute of the payment.xml file as per your business requirement.
E.g., I want to display credit card types in this order. VISA, MasterCard, American Express and then all others as it is. So following is what i have to update in the payment.xml file.

Magento 2 Credit Card Type Order

This change will update the sequence of credit card type at front-end checkout as well as in the admin. Check the following screenshot of the admin.

Magento 2 sequence of credit card

Thank you