Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

CreditCard Identifier - Java

Credit Card BIN validation library using bin-cc data.

Installation

Maven

<dependency>
    <groupId>br.com.s2n.creditcard</groupId>
    <artifactId>creditcard-identifier</artifactId>
    <version>2.1.0</version>
</dependency>

Gradle

implementation 'br.com.s2n.creditcard:creditcard-identifier:2.1.0'

Usage

import br.com.s2n.creditcard.identifier.CreditCardValidator;

public class Main {
    public static void main(String[] args) {
        CreditCardValidator validator = new CreditCardValidator();
        
        // Find brand
        String brand = validator.findBrand("4012001037141112");
        System.out.println(brand); // "visa"
        
        // Check if supported
        boolean supported = validator.isSupported("4012001037141112");
        System.out.println(supported); // true
        
        // Validate CVV
        boolean validCvv = validator.validateCvv("123", "visa");
        System.out.println(validCvv); // true
        
        // Luhn validation
        boolean validLuhn = CreditCardValidator.luhn("4012001037141112");
        System.out.println(validLuhn); // true
    }
}

Running the Example

# Compile
mvn compile

# Run tests
mvn test

# Run example
mvn exec:java -Dexec.mainClass="br.com.s2n.creditcard.identifier.Example"

Features

  • Brand Identification: Identify card brand by BIN/IIN patterns
  • CVV Validation: Validate CVV length for each brand
  • Luhn Algorithm: Validate card numbers using Luhn checksum
  • Detailed Brand Info: Get comprehensive brand information
  • Performance: Pre-compiled regex patterns for fast validation

Supported Brands

See data/compiled/BRANDS.md for the complete list.

License

MIT License