Credit Card Number

Credit Card Number is a Java library that can provide details of a bank issued credit card number.

Resources

The goal of this project is to use publicly and freely available documentation to create a reliable Java library to provide information about credit card numbers.

Some resources consulted are:

Design Principles

Download and Use in Projects

You can download the jar on the Maven Central Repository. The download page has instructions on how to use the library in your Maven or Gradle build.

Examples

How to Get Bank Card Information

To get bank card information, use code like:

AccountNumber pan = new AccountNumber("5266-0922-0141-6174");
ExpirationDate expiration = new ExpirationDate(2015, 4);
Name name = new Name("Sualeh", "Fatehi");
BankCard card = new BankCard(pan, expiration, name);
System.out.println(card);

and you will get this output:

Bank Card Information: 
  Raw Account Number: 5266-0922-0141-6174
  Primary Account Number: 5266092201416174
    Major Industry Identifier: 5 - Banking and financial
    Issuer Identification Number: 526609
    Card Brand: MasterCard
    Last Four Digits: 6174
    Passes Luhn Check? Yes
    Is Primary Account Number Valid? Yes
  Expiration Date: 1504
    Is Expired? No
  Name: Sualeh Fatehi

How to Secure the Credit Card Number

If you need the account number information, but want to be secure by not storing the actual primary account number in memory, you can use code like:

AccountNumber pan = new AccountNumber("5266-0922-0141-6174");
pan.dispose();
System.out.println(pan);

and you will get this output:

MasterCard-6174

Internationalization is Supported

You can use code like:

AccountNumber pan = new AccountNumber("५२६६ ०९२२ ०१४१ ६१७४");
System.out.println(pan);

and you will get this output:

5266092201416174