2017 © Pedro Peláez
 

library php-credit-card-validator

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

image

inacho/php-credit-card-validator

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

  • Thursday, July 30, 2015
  • by inacho
  • Repository
  • 22 Watchers
  • 116 Stars
  • 317,387 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 51 Forks
  • 14 Open issues
  • 4 Versions
  • 8 % Grown

The README.md

PHP Credit Card Validator

Build Status Coverage Status Latest Stable Version Total Downloads, (*1)

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date., (*2)

Installation

Require the package in composer.json, (*3)

"require": {
    "inacho/php-credit-card-validator": "1.*"
},

If you are using Laravel, add an alias in config/app.php, (*4)

'aliases' => array(

    'App'             => 'Illuminate\Support\Facades\App',
    ...
    'View'            => 'Illuminate\Support\Facades\View',

    'CreditCard'      => 'Inacho\CreditCard',

),

Usage

Validate a card number knowing the type:

$card = CreditCard::validCreditCard('5500005555555559', 'mastercard');
print_r($card);

Output:, (*5)

Array
(
    [valid] => 1
    [number] => 5500005555555559
    [type] => mastercard
)

Validate a card number and return the type:

$card = CreditCard::validCreditCard('371449635398431');
print_r($card);

Output:, (*6)

Array
(
    [valid] => 1
    [number] => 371449635398431
    [type] => amex
)

Validate the CVC

$validCvc = CreditCard::validCvc('234', 'visa');
var_dump($validCvc);

Output:, (*7)

bool(true)

Validate the expiration date

$validDate = CreditCard::validDate('2013', '07'); // past date
var_dump($validDate);

Output:, (*8)

bool(false)

Tests

Execute the following command to run the unit tests:, (*9)

vendor/bin/phpunit

The Versions

30/07 2015

dev-master

9999999-dev

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • lib-pcre >=7.3

 

The Development Requires

by Ignacio de Tomás

laravel validator cards creditcard card credit debit creditcards cvc

03/07 2015

1.0.2

1.0.2.0

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • lib-pcre >=7.3

 

The Development Requires

by Ignacio de Tomás

laravel validator cards creditcard card credit debit creditcards cvc

21/05 2015

1.0.1

1.0.1.0

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • lib-pcre >=7.3

 

by Ignacio de Tomás

laravel validator cards creditcard card credit debit creditcards cvc

27/11 2014

1.0.0

1.0.0.0

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • lib-pcre >=7.3

 

by Ignacio de Tomás

laravel validator cards creditcard card credit debit creditcards cvc