amiriskander/valid-credit-card

Validate credit and debit cards given their card numbers and cvc number

Downloads

16

Stars

1

Version

v1.0.1

Valid Credit Card

Build Status Latest Stable Version Total Downloads License

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

Resources

amiriskander

Author

amiriskander