PHPackages                             malith124/validate-credit-card - 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. malith124/validate-credit-card

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

malith124/validate-credit-card
==============================

PHP and Laravel credit card validator

1.0(1y ago)03MITPHPPHP ^8.0

Since Sep 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Malith1994124/laravel-validate-credit-card)[ Packagist](https://packagist.org/packages/malith124/validate-credit-card)[ RSS](/packages/malith124-validate-credit-card/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

PHP Validate Credit Card
========================

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

![Packagist](https://camo.githubusercontent.com/1dabb6b24ac15f44a35464202b61f6e185921b48e1ce8b68e2bb0e9bb1253fe6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72346b69622f76616c69646174652d6372656469742d636172642e737667)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date. Comes with minimal validation rules for Laravel

Disclaimer
----------

[](#disclaimer)

All the codes here come form 2 repository-

-
-

They should meet you requirements. I had to make this package to solve some very specific requirements.

Install
-------

[](#install)

Install via composer

```
composer require r4kib/validate-credit-card

```

Add Service Provider to `config/app.php` in `providers` section

```
R4kib\ValidateCreditCard\ServiceProvider::class,
```

PHP Usage
---------

[](#php-usage)

### Validate a card number knowing the type:

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

```
$card = CreditCard::validCreditCard('5500005555555559', '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', '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)

```

Laravel Usage
-------------

[](#laravel-usage)

Add this to your validation rules:

```
// Add this in your controller method
$this->validate($request, [
    'credit-card-number' => 'required|ccn',
    'credit-card-date' => 'required|ccd',
    'credit-validation-code' => 'required|cvc',
]);
```

Tests
-----

[](#tests)

Execute the following command to run the unit tests:`vendor/bin/phpunit`

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

612d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/36a5d578745065994ce52593245a3a666c6668826d167fd2462610563d0eee48?d=identicon)[malith124](/maintainers/malith124)

---

Top Contributors

[![Malith1994124](https://avatars.githubusercontent.com/u/18634794?v=4)](https://github.com/Malith1994124 "Malith1994124 (3 commits)")

---

Tags

phplaravelvalidatorcredit-card

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/malith124-validate-credit-card/health.svg)

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

###  Alternatives

[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[laravel-validation-rules/phone

Validate that a phone number is in the correct format

69355.5k](/packages/laravel-validation-rules-phone)[rap2hpoutre/laravel-credit-card-validator

Laravel credit card validator

22129.5k](/packages/rap2hpoutre-laravel-credit-card-validator)

PHPackages © 2026

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