card icon indicating copy to clipboard operation
card copied to clipboard

Disabling specific card types

Open RickKukiela opened this issue 7 years ago • 9 comments

I just found this great plugin (thanks!) but I was setting it up and I'm interested in defining which cards are actually supported. I mean they will fail at the gateway if they enter an unsupported card but I would like to just deny the card from the get go. Is this possible? I didn't see a configuration option for this.

RickKukiela avatar Jun 26 '17 23:06 RickKukiela

Rick, did you ever get a solution for this? I'd like to be able to do the same thing.

johnapolley avatar Mar 01 '18 16:03 johnapolley

Man that was a while ago, let me review the code and I'll let you know what I ended up doing.

RickKukiela avatar Mar 01 '18 17:03 RickKukiela

Thanks. I'd really appreciate it.

johnapolley avatar Mar 01 '18 17:03 johnapolley

So it looks like I ended up just leaving it to the gateway in this case. However you could easily run the number through a LUHN algorithm to detect the card type before sending it to the gateway in the back end code, however that's not really much better than just letting the gateway fail it.

Another option is to do the LUHN check in javascript. I havent tried, but you could probably do an onsubmit="return validate();" on the form where you can validate it there... or even on a keyup event on the card field.

RickKukiela avatar Mar 01 '18 17:03 RickKukiela

Thanks for the quick response. That was the approach I was working on. Was hoping there might be a way to restrict it built into the plugin.

johnapolley avatar Mar 01 '18 17:03 johnapolley

Would be a nice feature for someone to add :)

RickKukiela avatar Mar 01 '18 17:03 RickKukiela

Has anyone figured out how do restrict the types of cards that can be entered and pass the validator?

alexphelps avatar Mar 23 '18 17:03 alexphelps

I agree, I am not sure why there is support for 19 numbers for cards. Also can't format the date to MM/YY without third-party mask.

sgtcoder avatar Jun 18 '21 19:06 sgtcoder

@sgtcoder Have you tried the latest Card 2.5.3 and Payment 2.4.4?

I just removed the 19 digits for Visa here: https://github.com/jessepollak/payment/issues/150

melloware avatar Jun 19 '21 12:06 melloware