1. Go to this page and download the library: Download jlorente/php-credit-cards 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/ */
jlorente / php-credit-cards example snippets
$validator = new CreditCardValidator();
$validator = CreditCardValidator::make();
$validator = new CreditCardValidator([
CreditCardValidator::TYPE_VISA,
CreditCardValidator::TYPE_MASTERCARD,
]);
[
'example-card' => [
'niceType' => 'Test Card', // Display name
'type' => 'example-card', // Type/Code name
'patterns' => [ // Valid patterns for the card
272012, // Simple validator: true if the card begins with the pattern 272012
[5, 89], // Range validator: true if the card initial two digits value is between 5 and 89 both ' => [ // Security code configuration
'name' => 'CVV', // Name of the security code
'size' => 3, // Valid length of the security code
],
'luhnCheck' => true // To validate the Luhn's algorithm when calling matches
],
];
bash
$ php composer.phar
json
...
"rente/php-credit-cards": "*"
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.