Skip to content

Commit

Permalink
Merge pull request #689 from recurly/tarjeta-naranja-bins
Browse files Browse the repository at this point in the history
Add BIN range for Tarjeta Naranja
  • Loading branch information
chrissrogers authored Aug 19, 2021
2 parents c0ea23d + bb1c454 commit 30eb207
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/recurly/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ const TYPES = [
type: 'hipercard',
pattern: /^(606282\d{10}(\d{3})?)|(3841\d{15})$/,
lengths: [16]
},
{
type: 'tarjeta_naranja',
pattern: {
test: (n) => {
const firstEight = parseInt(n.substr(0, 8), 10);
const acceptedRanges = [
[58956200, 58956299]
];

return validBinRange(acceptedRanges, firstEight);
}
},
lengths: [16, 17, 18, 19]
}
];

Expand Down
5 changes: 5 additions & 0 deletions test/unit/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ describe('Recurly.validate', function () {
assert.strictEqual(recurly.validate.cardType('6062828888666688'), 'hipercard');
});

it('should parse Tarjeta Naranja', function () {
assert.strictEqual(recurly.validate.cardType('5895620000000002'), 'tarjeta_naranja');
assert.strictEqual(recurly.validate.cardType('5895629999999999'), 'tarjeta_naranja');
});

it('should parse unknown', function () {
assert.strictEqual(recurly.validate.cardType('867-5309-jenny'), 'unknown');
});
Expand Down

0 comments on commit 30eb207

Please sign in to comment.