Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date
imaddev/php-credit-card-validator is a Laravel package for validates popular debit and credit cards numbers against regular expressions and luhn algorithm. also validates the cvc and the expiration date.
It currently has 0 GitHub stars and 29 downloads on Packagist (latest version 1.0.4).
Install it with composer require imaddev/php-credit-card-validator.
Discover more Laravel packages by imaddev
or browse all Laravel packages to compare alternatives.
Last updated
Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date.
composer require imaddev/php-credit-card-validator
If you are using Laravel, add an alias in config/app.php
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
...
'View' => 'Illuminate\Support\Facades\View',
'CreditCard' => 'Inacho\CreditCard',
),
$card = CreditCard::validCreditCard('5500005555555559', 'mastercard');
print_r($card);
Output:
Array
(
[valid] => 1
[number] => 5500005555555559
[type] => mastercard
)
$card = CreditCard::validCreditCard('371449635398431');
print_r($card);
Output:
Array
(
[valid] => 1
[number] => 371449635398431
[type] => amex
)
$validCvc = CreditCard::validCvc('234', 'visa');
var_dump($validCvc);
Output:
bool(true)
$validDate = CreditCard::validDate('2013', '07'); // past date
var_dump($validDate);
Output:
bool(false)
Execute the following command to run the unit tests:
vendor/bin/phpunit