malith124/validate-credit-card is a Laravel package for php and laravel credit card validator.
It currently has 0 GitHub stars and 3 downloads on Packagist (latest version 1.0).
Install it with composer require malith124/validate-credit-card.
Discover more Laravel packages by malith124
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. Comes with minimal validation rules for Laravel
All the codes here come form 2 repository-
They should meet you requirements. I had to make this package to solve some very specific requirements.
Install via composer
composer require r4kib/validate-credit-card
Add Service Provider to config/app.php in providers section
R4kib\ValidateCreditCard\ServiceProvider::class,
$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)
Add this to your validation rules:
// Add this in your controller method
$this->validate($request, [
'credit-card-number' => 'required|ccn',
'credit-card-date' => 'required|ccd',
'credit-validation-code' => 'required|cvc',
]);
Execute the following command to run the unit tests:vendor/bin/phpunit