PHPackages                             coatesap/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. coatesap/credit-card-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

coatesap/credit-card-validator
==============================

A simple PHP class for validating credit/debit card details

v2.0(11y ago)82247[1 PRs](https://github.com/coatesap/credit-card-validator/pulls)MITPHP

Since Dec 2Pushed 9y ago2 watchersCompare

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

READMEChangelog (3)DependenciesVersions (5)Used By (0)

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

[](#credit-card-validator)

A simple PHP class for preparing and validating credit/debit card details. Typically this takes place before they are passed to a payment gateway for processing.

Example Usage
-------------

[](#example-usage)

```
require '../vendor/autoload.php';

$cardDetails = array(
    'number' =>'4929000000006',
    'expiryYear' => 2013,
    'expiryMonth' => 5,
    'code' => '123'
);

$card = new Coatesap\Payment\Card();
$card->populate($cardDetails);

if (!$card->isValid($message)) {
    // show error message (set by reference)
    echo 'There is a problem with your card details: ' . $message;
} else {
    // get the prepped, validated card data as an array
    $cardData = $card->toArray();
    // send $cardData to payment gateway
}
```

Installation
------------

[](#installation)

The credit card class can be installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file:

```
{
    "require": {
        "coatesap/credit-card-validator": "~2.0"
    }
}
```

Data preparation
----------------

[](#data-preparation)

This class does some simple preparation of your card data. This includes removing non-numeric characters, including spaces, from:

- The card number
- The CVC/CV2 value
- The card expiry date

Validation Checks
-----------------

[](#validation-checks)

This class also checks:

- That the card hasn't expired
- A valid CVC/CV2 security code has been supplied
- The card number passes the Luhn check

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

4

Last Release

4176d ago

Major Versions

v1.2 → v2.02014-12-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff62e9d8c1b4833b67d772a5273bff97c4e2f10ff79eef9efcfb67fb1bc4a5d4?d=identicon)[coatesap](/maintainers/coatesap)

---

Top Contributors

[![silici0](https://avatars.githubusercontent.com/u/61994?v=4)](https://github.com/silici0 "silici0 (8 commits)")

### Embed Badge

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

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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