CreditcardIdentifier (CreditCard Identifier v2.3.0)

View Source

Credit Card BIN Validator

This module provides credit card validation using bin-cc data.

Examples

brand = CreditcardIdentifier.find_brand("4012001037141112")
# Returns %{name: "visa", ...}

CreditcardIdentifier.supported?("4012001037141112")
# Returns true

Summary

Functions

Identify the credit card brand.

Get information about a specific brand.

Get information about a specific brand with custom brands list.

Get detailed information about a specific brand.

Get all brand data.

Get all detailed brand data.

List all supported brands.

List all supported brands from custom brands list.

Validate a credit card number using the Luhn algorithm.

Check if card number is supported.

Check if card number is supported with custom brands list.

Validate CVV for a specific brand.

Validate CVV for a specific brand with custom brands list.

Functions

find_brand(card_number, opts \\ [])

Identify the credit card brand.

Parameters

  • card_number: Credit card number as string
  • opts: Keyword list with options
    • detailed: boolean, if true returns detailed brand info (default: false)

Returns

Brand map or nil if not found. If detailed: true, includes :matched_pattern and :matched_bin fields.

Examples

iex> brand = CreditcardIdentifier.find_brand("4012001037141112")
iex> brand.name
"visa"

iex> brand = CreditcardIdentifier.find_brand("4012001037141112", detailed: true)
iex> brand.scheme
"visa"

get_brand_info(brand_name)

Get information about a specific brand.

Parameters

  • brand_name: Brand name (e.g., "visa", "mastercard")

Returns

Brand map or nil if not found

get_brand_info(brand_name, brands)

Get information about a specific brand with custom brands list.

Parameters

  • brand_name: Brand name (e.g., "visa", "mastercard")
  • brands: List of brand data

Returns

Brand map or nil if not found

get_brand_info_detailed(scheme)

Get detailed information about a specific brand.

Parameters

  • scheme: Scheme name (e.g., "visa", "mastercard")

Returns

Detailed brand map or nil if not found

get_brands()

Get all brand data.

Returns

List of brand maps with pre-compiled regex patterns

get_brands_detailed()

Get all detailed brand data.

Returns

List of detailed brand maps

list_brands()

List all supported brands.

Returns

List of brand names

list_brands(brands)

List all supported brands from custom brands list.

Parameters

  • brands: List of brand data

Returns

List of brand names

luhn(number)

Validate a credit card number using the Luhn algorithm.

Parameters

  • number: Credit card number as string (digits only)

Returns

true if valid according to Luhn algorithm, false otherwise

Examples

iex> CreditcardIdentifier.luhn("4012001037141112")
true

iex> CreditcardIdentifier.luhn("1234567890123456")
false

supported?(card_number)

Check if card number is supported.

Parameters

  • card_number: Credit card number as string

Returns

true if supported, false otherwise

Examples

iex> CreditcardIdentifier.supported?("4012001037141112")
true

supported?(card_number, brands)

Check if card number is supported with custom brands list.

Parameters

  • card_number: Credit card number as string
  • brands: List of brand data

Returns

true if supported, false otherwise

validate_cvv(cvv, brand_or_name)

Validate CVV for a specific brand.

Parameters

  • cvv: CVV code as string
  • brand_or_name: Brand name (string) or brand map from find_brand

Returns

true if valid, false otherwise

validate_cvv(cvv, brand_or_name, brands)

Validate CVV for a specific brand with custom brands list.

Parameters

  • cvv: CVV code as string
  • brand_or_name: Brand name (string) or brand map from find_brand
  • brands: List of brand data

Returns

true if valid, false otherwise