PHPackages                             selay/php-credit-card-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. selay/php-credit-card-validator

ActiveLibrary[Payment Processing](/categories/payments)

selay/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.

4.0(4y ago)09.4k1MITPHPPHP &gt;=7.0

Since Nov 27Pushed 4y agoCompare

[ Source](https://github.com/selay/php-credit-card-validator)[ Packagist](https://packagist.org/packages/selay/php-credit-card-validator)[ RSS](/packages/selay-php-credit-card-validator/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (2)Versions (13)Used By (1)

PHP Credit Card Validator
=========================

[](#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.

Since original project seems to be abandoned, this fork is made to support other existing repos with compatible namespaces such as rap2hpoutre/laravel-credit-card-validator which also appears to be abondoned. I forked it to selay/laravel-credit-card-validator

Requirements
============

[](#requirements)

PHP 7.0+.

Require the package in `composer.json`

```
"require": {
    "selay/php-credit-card-validator": "4.*"
},
```

Usage
-----

[](#usage)

### Validate a card number knowing the type:

[](#validate-a-card-number-knowing-the-type)

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

Output:

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

```

### Validate a card number against several types:

[](#validate-a-card-number-against-several-types)

```
$card = CreditCard::validCreditCard('5500005555555559', [CreditCard::TYPE_VISA, CreditCard::TYPE_MASTERCARD]);
print_r($card);
```

Output:

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

```

### Validate a card number and return the type:

[](#validate-a-card-number-and-return-the-type)

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

Output:

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

```

### Validate the CVC

[](#validate-the-cvc)

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

Output:

```
bool(true)

```

### Validate the expiration date

[](#validate-the-expiration-date)

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

Output:

```
bool(false)

```

Tests
-----

[](#tests)

Execute the following command to run the unit tests:

```
vendor/bin/phpunit

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~265 days

Recently: every ~228 days

Total

10

Last Release

1804d ago

Major Versions

1.0.2 → 2.0.02018-12-05

2.0.0 → 3.0.02018-12-06

3.2.2 → 4.02021-06-09

PHP version history (4 changes)1.0.0PHP &gt;=5.3.0

2.0.0PHP &gt;=7.1

3.2.0PHP &gt;=7.2

4.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/74bf2d5fdc8db9f8224c46b46cfda918ae8790e1b9a7d0a0f0a833c894e570ba?d=identicon)[selay](/maintainers/selay)

---

Top Contributors

[![inacho](https://avatars.githubusercontent.com/u/742624?v=4)](https://github.com/inacho "inacho (16 commits)")[![TheMY3](https://avatars.githubusercontent.com/u/9335727?v=4)](https://github.com/TheMY3 "TheMY3 (14 commits)")[![thedotedge](https://avatars.githubusercontent.com/u/227241?v=4)](https://github.com/thedotedge "thedotedge (6 commits)")[![pridumkuvatyj](https://avatars.githubusercontent.com/u/18462555?v=4)](https://github.com/pridumkuvatyj "pridumkuvatyj (4 commits)")[![naaando](https://avatars.githubusercontent.com/u/12532760?v=4)](https://github.com/naaando "naaando (3 commits)")[![medinskiy](https://avatars.githubusercontent.com/u/9282433?v=4)](https://github.com/medinskiy "medinskiy (2 commits)")

---

Tags

validatorpaymentcreditcardcardcreditdebitcvc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/selay-php-credit-card-validator/health.svg)

```
[![Health](https://phpackages.com/badges/selay-php-credit-card-validator/health.svg)](https://phpackages.com/packages/selay-php-credit-card-validator)
```

###  Alternatives

[freelancehunt/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.

18620.4k2](/packages/freelancehunt-php-credit-card-validator)[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

2051.4M11](/packages/inacho-php-credit-card-validator)[league/omnipay

Omnipay payment processing library

6.1k9.7M166](/packages/league-omnipay)[mrprompt/cielo

Integration with Cielo gateway.

481.9k1](/packages/mrprompt-cielo)[cometcult/braintree-bundle

Symfony 2 Bundle for Braintree's PHP client library

2185.9k](/packages/cometcult-braintree-bundle)[omise/omise-magento

Accept payments on your Magento 2 website with Omise

3418.8k](/packages/omise-omise-magento)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
