PHP code example of designbycode / credit-card-validator

1. Go to this page and download the library: Download designbycode/credit-card-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

designbycode / credit-card-validator example snippets


$card = new CreditCardValidator('4111 1111 1111 1111');
if ($card->isValid()) {
    echo 'Credit card number is valid';
} else {
    echo 'Credit card number is invalid';
}

$validator = new ExpiryDateValidator(12, 2025);
if ($validator->isValid()) {
    echo 'Expiry date is valid';
} else {
    echo 'Expiry date is invalid';
}

$validator = new CvvValidator('123', 'visa');
or 
$card = new CreditCardValidator('4111 1111 1111 1111')
$validator = new CvvValidator('123', $card->getCardType());

if ($validator->isValid()) {
    echo 'CVV code is valid';
} else {
    echo 'CVV code is invalid';
}