Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the card type (visa, mastercard, etc.) so I can pass that info to payment gateway #604

Open
frankkreutzer opened this issue Feb 16, 2023 · 3 comments

Comments

@frankkreutzer
Copy link

frankkreutzer commented Feb 16, 2023

I'd like to be able to pass the card type as we want to display it later on.

@frankkreutzer frankkreutzer changed the title How to get the card type (visa, mastercard, etc.) so I can pass that info How to get the card type (visa, mastercard, etc.) so I can pass that info to payment gateway Feb 16, 2023
@03lenio
Copy link

03lenio commented May 18, 2023

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.

@ovicko
Copy link

ovicko commented Jun 16, 2023

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)
}

@Almansori
Copy link

$('#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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants