PHPackages                             freelancehunt/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. freelancehunt/php-credit-card-validator

ActiveLibrary[Payment Processing](/categories/payments)

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.

3.2.2(5y ago)18620.4k↓11.3%8[1 issues](https://github.com/freelancehunt/php-credit-card-validator/issues)2MITPHPPHP &gt;=7.2

Since Nov 27Pushed 5y ago3 watchersCompare

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

READMEChangelog (6)Dependencies (2)Versions (12)Used By (2)

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

[](#php-credit-card-validator)

[![Build Status](https://camo.githubusercontent.com/2f540345668a08fb92bc4fb8b1627444f68fd53ea9341312bc62bc4d8dffba02/68747470733a2f2f7472617669732d63692e636f6d2f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/freelancehunt/php-credit-card-validator)[![codecov](https://camo.githubusercontent.com/cf181791c7b5591aad864d8d40c6d78b00d3097025f1d7013c94ed01b2ccfe81/68747470733a2f2f636f6465636f762e696f2f67682f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/freelancehunt/php-credit-card-validator)[![PHP from Packagist](https://camo.githubusercontent.com/2d79213a778d9f29d925e32464027ae70b774b2532cf73552b4dd3f6c65765e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722e737667)](https://camo.githubusercontent.com/2d79213a778d9f29d925e32464027ae70b774b2532cf73552b4dd3f6c65765e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722e737667)[![Packagist](https://camo.githubusercontent.com/3c34a9b686c84f8097677cee02103f676d77534addca7458455c477f344a4811/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722e737667)](https://packagist.org/packages/freelancehunt/php-credit-card-validator)[![Packagist](https://camo.githubusercontent.com/31f449db5c4f2cd227816661a72522b9763e67af2bd9766013659607d5ada8fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722e737667)](https://packagist.org/packages/freelancehunt/php-credit-card-validator)[![License](https://camo.githubusercontent.com/402d51a0d604b665d7a6a4f9e5a1b4494742b77ab7b59e7a6324726aa51982ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f667265656c616e636568756e742f7068702d6372656469742d636172642d76616c696461746f722e737667)](https://coveralls.io/github/freelancehunt/php-credit-card-validator?branch=master)

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, we plan to maintain this fork.

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

[](#requirements)

PHP 7.1+. We don't plan to support [EOL](http://php.net/supported-versions.php) PHP versions.

Require the package in `composer.json`

```
"require": {
    "freelancehunt/php-credit-card-validator": "3.*"
},
```

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

42

—

FairBetter than 90% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community21

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 ~280 days

Recently: every ~193 days

Total

9

Last Release

1949d ago

Major Versions

1.0.2 → 2.0.02018-12-05

2.0.0 → 3.0.02018-12-06

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

2.0.0PHP &gt;=7.1

3.2.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/169601c76b2d23fd5fd48d6e282f8cee5090b5b80742f436b962893dbaee29fb?d=identicon)[thedotedge](/maintainers/thedotedge)

---

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/freelancehunt-php-credit-card-validator/health.svg)

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

###  Alternatives

[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)
