Skip to main content

Credit card BIN validation using bin-cc data

Project description

Credit Card Identifier - Python Library

Python library for credit card BIN validation using bin-cc data.

Installation

pip install creditcard-identifier

Usage

Basic Validation

from creditcard_identifier import find_brand, is_supported

# Identify card brand
brand = find_brand('4012001037141112')
print(brand)  # 'visa'

# Check if card is supported
supported = is_supported('4012001037141112')
print(supported)  # True

Using the Validator Class

from creditcard_identifier import CreditCardValidator

validator = CreditCardValidator()

# Identify brand
brand = validator.find_brand('4012001037141112')
print(brand)  # 'visa'

# Check if supported
supported = validator.is_supported('4012001037141112')
print(supported)  # True

# Validate CVV
valid = validator.validate_cvv('123', 'visa')
print(valid)  # True

# Get brand info
info = validator.get_brand_info('visa')
print(info['regexpBin'])

# List all brands
brands = validator.list_brands()
print(brands)  # ['elo', 'diners', 'visa', ...]

API

Module Functions

find_brand(card_number)

Identify the credit card brand.

Parameters:

  • card_number (str): The credit card number

Returns: (str) Brand name (e.g., 'visa', 'mastercard') or None if not found

is_supported(card_number)

Check if the card number is supported.

Parameters:

  • card_number (str): The credit card number

Returns: (bool) True if supported, False otherwise

CreditCardValidator Class

__init__(data_path=None)

Initialize validator with brand data.

Parameters:

  • data_path (str, optional): Path to brands.json. If None, uses bundled data.

find_brand(card_number)

Identify the credit card brand.

Parameters:

  • card_number (str): The credit card number

Returns: (str) Brand name or None if not found

is_supported(card_number)

Check if card number is supported.

Parameters:

  • card_number (str): The credit card number

Returns: (bool) True if supported, False otherwise

validate_cvv(cvv, brand_name)

Validate CVV for a specific brand.

Parameters:

  • cvv (str): CVV code
  • brand_name (str): Brand name (e.g., 'visa', 'mastercard')

Returns: (bool) True if valid, False otherwise

get_brand_info(brand_name)

Get information about a specific brand.

Parameters:

  • brand_name (str): Brand name

Returns: (dict) Brand information or None if not found

list_brands()

List all supported brands.

Returns: (list) List of brand names

Data Source

This library uses the BIN data from the bin-cc project.

The data is bundled with the package, and can be updated by installing a newer version of the package.

Development

Install in Development Mode

cd libs/python
pip install -e .

Run Tests

python -m pytest tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

creditcard_identifier-2.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

creditcard_identifier-2.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file creditcard_identifier-2.0.0.tar.gz.

File metadata

  • Download URL: creditcard_identifier-2.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for creditcard_identifier-2.0.0.tar.gz
Algorithm Hash digest
SHA256 143339b705ddcf56539a68a20bfc6222fa89d0d88e72957b0f53735d8d6eb6a6
MD5 012ed41b9c47e6e28c8b2b495adac1f5
BLAKE2b-256 cedcfe09c1de905c42eb989474c94a2a23b32dafe3c72b26dc49733ae15d9b72

See more details on using hashes here.

Provenance

The following attestation bundles were made for creditcard_identifier-2.0.0.tar.gz:

Publisher: release.yml on renatovico/bin-cc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file creditcard_identifier-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for creditcard_identifier-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 811de15d2415570c6ad5241aaf7994c138918471e3c6399f7c4fe29367bd8108
MD5 aa3d87170de0aef00dab6e3e97b2f36c
BLAKE2b-256 be7a37db9bdcbbd86df8eb22d30146f5d54500fdbf745161ce589e0a36aa69bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for creditcard_identifier-2.0.0-py3-none-any.whl:

Publisher: release.yml on renatovico/bin-cc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page