Package Data | |
---|---|
Maintainer Username: | inacho |
Maintainer Contact: | nacho@inacho.es (Ignacio de Tomás) |
Package Create Date: | 2014-09-30 |
Package Last Update: | 2023-08-22 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:08:13 |
Package Statistics | |
---|---|
Total Downloads: | 1,304,597 |
Monthly Downloads: | 5,398 |
Daily Downloads: | 26 |
Total Stars: | 199 |
Total Watchers: | 20 |
Total Forks: | 104 |
Total Open Issues: | 22 |
Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date.
Require the package in composer.json
"require": {
"inacho/php-credit-card-validator": "1.*"
},
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