card
card copied to clipboard
How to get the card type (visa, mastercard, etc.) so I can pass that info to payment gateway
I'd like to be able to pass the card type as we want to display it later on.
not sure if this is still relevant but for people with the same question: you can use the bin of the card to decode if it's type, the bin is the bank identification number of each card and it identifies a card down to the bank which issued it, with a BIN API like the one from binlist.io you are easily able to check which card goes with which card type.
I noticed there is an inbuilt payment library which documents the APIs available.
You don't need to download the library to use it.
In my case:
Form field
<input type="text" id="card-number" class="form-control" placeholder="0000 0000 0000 0000" type="tel" name="number">
Get type
$("#button-confirm").click(function() {
var type= Payment.fns.cardType($('#card-number').val())
console.log(type)
}
$('#someTextBox').change(function() { $('#someOutput').text(creditCardTypeFromNumber($(this).val())); }); This will output into some element with id="someOutput" the result of the text box which fires when the user changes the text in the element id="someTextBox".
How to check for username and password correct logins to a credit card site...to provide details