Hi!
There’s a service that validates the credit card number and returns the metadata.
The requisition is via http and returns a json. Just like this:
curl -H "Accept-Version: 3" "https://lookup.binlist.net/45717360"
{
"number": {
"length": 16,
"luhn": true
},
"scheme": "visa",
"type": "debit",
"brand": "Visa/Dankort",
"prepaid": false,
"country": {
"numeric": "208",
"alpha2": "DK",
"name": "Denmark",
"emoji": "🇩🇰",
"currency": "DKK",
"latitude": 56,
"longitude": 10
},
"bank": {
"name": "Jyske Bank",
"url": "www.jyskebank.dk",
"phone": "+4589893300",
"city": "Hjørring"
}
}
The link: https://binlist.net/
But if you want regex for the most common credit card brands, check below.