A powerful library for credit card parsing, validation, and formatting
Project description
CCParser - Powerful Credit Card Parsing & Validation Library
CCParser is a robust and efficient Python library designed for seamless credit card parsing, validation, and formatting. Whether you're extracting card details, validating numbers, or formatting them for display, CCParser makes the process effortless with its powerful features and intuitive API.
🚀 Features
- 🔍 Smart Extraction: Extracts card number, expiry date (month/year), and CVV from a string.
- 📏 Standardized Formatting: Converts card numbers into
xxxx xxxx xxxx xxxxformat. - ✅ Luhn Validation: Ensures card validity using the industry-standard Luhn algorithm.
- 🗓️ Expiry & CVV Checks: Validates expiry date and CVV length based on card type.
- 💳 Card Type Detection: Identifies major card providers (Visa, MasterCard, AMEX, etc.).
- 🔒 Masked Output Option: Returns a masked format (
**** **** **** 5379). - 🔗 Multiple Delimiters: Supports delimiters like
|,:, and spaces. - 📆 Flexible Expiry Handling: Accepts expiry years in both
YYYYandYYformats. - ⚡ Easy-to-Use API: Well-structured API for seamless integration.
- 🖥️ Command-Line Support: Provides a CLI tool for quick parsing.
- 📖 Well-Documented: Extensive Markdown documentation (
README.md). - 📦 PyPI Ready: Structured for easy PyPI distribution.
- 🛠️ CI/CD Integration: Uses GitHub Actions for automated testing.
- 🆕 Card Number Generation: Generate valid card numbers for testing purposes.
- 🆕 Additional Card Types: Supports JCB, Diners Club, and UnionPay.
⚠️ Disclaimer
This library is intended for educational and legitimate purposes only.
CCParser is designed to assist developers in:
- Building payment processing systems
- Testing and validating payment integrations
- Educational purposes and learning about payment card industry standards
- Fraud detection and prevention systems
Prohibited Uses:
- Unauthorized access to financial systems or data
- Credit card fraud, carding, or any form of financial crime
- Harvesting, storing, or processing stolen card information
- Any activity that violates applicable laws or regulations
By using this library, you agree to comply with all applicable laws, including but not limited to PCI-DSS standards, and take full responsibility for your use of this software. The author(s) are not responsible for any misuse or illegal activities conducted with this tool.
If you suspect fraudulent activity, please report it to your local authorities.
💳 Supported Card Types
CCParser recognizes and validates multiple card providers:
- Visa:
^4[0-9]{12}(?:[0-9]{3})?$ - MasterCard:
^5[1-5][0-9]{14}$ - American Express (AMEX):
^3[47][0-9]{13}$ - Discover:
^6(?:011|5[0-9]{2})[0-9]{12}$ - JCB:
^(?:2131|1800|35\d{3})\d{11}$ - Diners Club:
^3(?:0[0-5]|[68][0-9])[0-9]{11}$ - UnionPay:
^62[0-9]{14,17}$
📥 Installation
Install CCParser using pip:
pip install ccparser
📝 Usage Examples
Supported Card Formats
CCParser supports various card formats with different delimiters and expiry formats:
4111111111111111|12/30|123
4111111111111111|12|2030|123
4111111111111111|12|30|123
4111111111111111 12 2030 123
4111111111111111 12 30 123
4111111111111111:12:2030:123
4111111111111111:12:30:123
Python API
from ccparser import CCParser
card = CCParser("4111111111111111|12|2030|123")
print(card.get_number()) # 4111111111111111
print(card.get_formatted_number()) # 4111 1111 1111 1111
print(card.get_expiry()) # 12/30
print(card.get_cvv()) # 123
print(card.is_valid()) # True
print(card.get_card_type()) # Visa
print(card.get_masked_number()) # **** **** **** 1111
print(card.get_year()) # 2030
print(card.get_month()) # 12
print(card.get_card_details()) # Detailed card information
Card Number Generation
from ccparser.generator import generate_card_number
print(generate_card_number("Visa")) # Generates a valid Visa card number
print(generate_card_number("MasterCard")) # Generates a valid MasterCard number
CLI Tool
CCParser can also be used via the command line:
ccparser "4111111111111111|12|2030|123"
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please review our CONTRIBUTING guidelines before submitting a pull request.
📚 Acknowledgements
📧 Contact
For any inquiries or issues, feel free to reach out:
📩 Vihanga Indusara - vihangadev@gmail.com
CCParser – Simplifying credit card parsing, one line at a time! 🚀
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ccparser-1.0.0.tar.gz.
File metadata
- Download URL: ccparser-1.0.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da91360ade6b7ca8857130b7227e5fd0e0b9d82061488c9d25314f3cb71e05f6
|
|
| MD5 |
a5a13ca589a146a2a560123d9d51d42c
|
|
| BLAKE2b-256 |
509b26537d61de74b5218a66d043e388194fe9bb9b85a8a46b1644faae200a1e
|
File details
Details for the file ccparser-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ccparser-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7400a136a7e5d3b8c7f53b5cf9dfb640bce805528b29ebf7e82509cdb3e3cc11
|
|
| MD5 |
2e593fd2c783166fdcefbc1c8f9e6c96
|
|
| BLAKE2b-256 |
bc2d0af3a82ac5911c53228c82aee0bd43732b144176508845ece13dbb5ef944
|