Tag Archives: visa

Credit Card Metadata and Validator

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.

    const elo = /((((636368)|(438935)|(504175)|(451416)|(636297)))[0-9]{4}$)|(((5067)|(4576)|(4011))[0-9]{8}$)$/;
    const visa = /^4[0-9]{12}(?:[0-9]{3})$/;
    const master = /^5[1-5][0-9]{14}$/;
    const amex = /^3[47][0-9]{13}$/;
    const diners = /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/;
    const discover = /^6(?:011|5[0-9]{2})[0-9]{12}$/;
    const jcb = /^(?:2131|1800|35\d{3})\d{11}$/;
That’s it!