Full width home advertisement

Post Page Advertisement [Top]

Visa Card, Credit Card, Master Card

Hello,
If you want to get card type i.e. Visa, Master, Rupay etc. by card number, here is the code you can use.

This code uses regex for filtering out card type. You can use this method for getting the card type from card number (without space separation).



public String getCardType(String mCardNumber) {
        if (mCardNumber.startsWith("4")) {
            return "VISA";
        }else if (mCardNumber.matches("^508[5-9][0-9][0-9]|60698[5-9]|60699[0-9]|607[0-8][0-9][0-9]|6079[0-7][0-9]|60798[0-4]|(?!608000)608[0-4][0-9][0-9]|608500|6521[5-9][0-9]|652[2-9][0-9][0-9]|6530[0-9][0-9]|6531[0-4][0-9]")){
            return "RUPAY";
        } else if (mCardNumber.matches("^((6304)|(6706)|(6771)|(6709))[\\d]+")) {
            return "LASER";
        } else if (mCardNumber.matches("6(?:011|5[0-9]{2})[0-9]{12}[\\d]+")) {
            return "LASER";
        } else if (mCardNumber.matches("(5[06-8]|6\\d)\\d{14}(\\d{2,3})?[\\d]+") || mCardNumber.matches("(5[06-8]|6\\d)[\\d]+") || mCardNumber.matches("((504([435|645|774|775|809|993]))|(60([0206]|[3845]))|(622[018])\\d)[\\d]+")) {
            
            return "MAESTRO";
        } else if (mCardNumber.matches("^5[1-5][\\d]+")) {
            return "MASTER";
        } else if (mCardNumber.matches("^3[47][\\d]+")) {
            return "AMEX";
        } else if (mCardNumber.startsWith("36") || mCardNumber.matches("^30[0-5][\\d]+") || mCardNumber.matches("2(014|149)[\\d]+")) {
            return "DINR";
        } else if (mCardNumber.matches("^35(2[89]|[3-8][0-9])[\\d]+")) {
            return "JCB";
        }
        return "";
    }



[PHP]How to get credit card/debit card type(i.e. Visa, Master) from card number

1 comment:

  1. These JavaScript classes are led by web design and web development experts. Learn JavaScript and jQuery in these regularly scheduled public JavaScript training sessions. You can also schedule a private JavaScript course for you or your organizations. Regularly scheduled public JavaScript courses also cover jQuery and modern frameworks, and the introductory courses do not require any previous JavaScript experience.  free udemy courses to learn javascript

    ReplyDelete

Bottom Ad [Post Page]

| Designed by Colorlib