Skip to content

Commit

Permalink
Move credit card types to lib/const
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaslise committed Jul 12, 2022
1 parent b3489a5 commit cffa3c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/recurly/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FIELDS as CARD_FIELDS } from './token';
import each from 'component-each';
import find from 'component-find';
import { parseCard } from '../util/parse-card';
import creditCardTypes from './credit_card_types.json';
import CREDIT_CARD_TYPES from '../const/credit-card-types.json';

const debug = require('debug')('recurly:validate');

Expand Down Expand Up @@ -122,14 +122,14 @@ export function cardType (number, partial = false) {

const compareValue = buildCompareValue(cardNumber, compareLength, '0');

const types = Object.keys(creditCardTypes).filter((type) => {
const types = Object.keys(CREDIT_CARD_TYPES).filter((type) => {
if (partial && type == 'maestro') {
// Maestro has a wide range (6*) that overlaps with some other types,
// which can be disambiguated only when the full lenght is given
return;
}

return find(creditCardTypes[type], ((group) => {
return find(CREDIT_CARD_TYPES[type], ((group) => {
if (!partial && group.lengths.indexOf(cardNumber.length) < 0) {
return false;
}
Expand Down

0 comments on commit cffa3c4

Please sign in to comment.