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

Set cc_type server-side in case of js failure #3918

Conversation

NathanielWroblewski
Copy link
Contributor

Currently, cc_type is set on the client-side using jquery.payments. This creates a single point of failure at malfunctioning or disabled javascript given that the lack of a cc_type on a payment source causes some spree gateways to fail. This pull request adds a redundant check on the server-side for cases where the javascript either fails or is disabled.

  • Change CreditCard#expiry= to remove whitespace and split on '/' instead of splitting on ' / ' because when js fails, a user entry of '04/12' will break.
  • Change CreditCard#cc_type= to match a type based on the card number when cc_type is an empty string, as is the case when js fails.

@radar
Copy link
Contributor

radar commented Oct 31, 2013

Looks good to me. Thanks @NathanielWroblewski for the terrific work.

@radar
Copy link
Contributor

radar commented Oct 31, 2013

Applied this commit to my 2-1-stable and master branches.

radar pushed a commit that referenced this pull request Oct 31, 2013
@radar radar closed this in be1be71 Oct 31, 2013
@NathanielWroblewski
Copy link
Contributor Author

My pleasure, @radar. Thanks!

jhawthorn added a commit to jhawthorn/solidus that referenced this pull request Sep 28, 2016
The existing hash was incomplete, missing some brands. It
was also missing MasterCard's new (October 2016) BIN range
(222100-272099).

This hash was originally added in
spree/spree#3918
and has not been changed since. I don't know the original source, but I
would rather trust the Hash taken from ActiveMerchant.

One notable difference is that this will treat maestro and mastercard as
separate brands.

NB: For most stores, this code will not be run, and instead
jquery.payment on the frontend will be responsible for providing the
credit card brand.
bbuchalter pushed a commit to TommyJohnWear/solidus that referenced this pull request Nov 18, 2016
The existing hash was incomplete, missing some brands. It
was also missing MasterCard's new (October 2016) BIN range
(222100-272099).

This hash was originally added in
spree/spree#3918
and has not been changed since. I don't know the original source, but I
would rather trust the Hash taken from ActiveMerchant.

One notable difference is that this will treat maestro and mastercard as
separate brands.

NB: For most stores, this code will not be run, and instead
jquery.payment on the frontend will be responsible for providing the
credit card brand.
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

Successfully merging this pull request may close these issues.

2 participants