amiriskander / valid-credit-card
Validate credit and debit cards given their card numbers and cvc number
v1.0.1
2020-01-17 20:27 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: >=6.5.14
This package is auto-updated.
Last update: 2024-11-18 07:59:56 UTC
README
Simple and lightweight package that validates credit cards and debit cards for popular providers.
It validates cards against their card number lengths, card number patterns, CVC length and using Luhn algorithm if it were supported by the provider.
Installation
Require the package using composer
composer require amiriskander/valid-credit-card
Or add it manually to composer.json
in the list of dependencies under require
"require": { "amiriskander/valid-credit-card": "*" },
Usage
Validate Credit/Debit card:
use AmirIskander\CreditCard\CreditCardValidator; $cardValidator = new CreditCardValidator(); $isValid = $cardValidator->validateCreditCard('4539392426082460', '123'); var_dump($isValid);
Output:
bool(true)
Tests
Execute the below command to run the unit tests:
vendor/bin/phpunit tests