How to Validation Credit Card PHP Laravel ??
there is a question in mind for some Developers How do some Websites check the type of Credit Card and then Submit it to the API Visa or Master Card, etc. … How is this Working?
I will today offer a library in Laravel to Provide the Solution in just 2 lines of Code !!
https://github.com/sfyanbel/CreditCardValidation
How to install it in your Laravel Project?
composer require sfyanbel/credit-card-validation
How to use
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use sfyanbel\CreditCardValidation\CreditCard;
class TestController extends Controller
{
function test(){
$ob = new CreditCard();
return $ob->getTypeCreditCard("43943418067844");
}
}
in This Example, we use this Card "43943418067844" and this will return the Following ['Visa',2]
first index name of the Card
second index id of the Card
and for other Card, you will find this
['AmericanExpress',1] , ['Visa',2] , ['MasterCards',3] , ['Discover',4]
and for other numbers not Defined
['String incorrect'];
This is in case the length of the card numbers is incorrect
['The count of digits is incorrect'];
Top comments (0)