braintree / credit-card-type

A library for determining credit card type
MIT License
980 stars 154 forks source link

Incorrect type #107

Closed gabrielozaki closed 4 years ago

gabrielozaki commented 4 years ago

General information

Issue description

I have this test bin: "504175" and it's a ELO, confirmed by ccbins, freebinchecker, bincodes and the legacy system that i was working. But I'm getting a Maestro result:

const creditCardType = require('credit-card-type');

const eloCard = creditCardType('504175');
console.log(eloCard);

Output:

[ { niceType: 'Maestro',
    type: 'maestro',
    patterns: [ 493698, [Array], [Array], [Array], 63, 67, 6 ],
    gaps: [ 4, 8, 12 ],
    lengths: [ 12, 13, 14, 15, 16, 17, 18, 19 ],
    code: { name: 'CVC', size: 3 },
    matchStrength: 6 } ]

There any place where i can get a updated bin table and make a PR to correct this issue?

crookedneighbor commented 4 years ago

Was able to reproduce this.

504175 is listed as an elo card number: https://github.com/braintree/credit-card-type/blob/401f82161e630beec72903370313898230e25cbc/lib/card-types.js#L163

So it's likely that the maestro ranges need to be updated to accommodate it. Right now, maestro is showing a an identical match strength for 504175 with ELO, and since it has a higher preference in the card test order, it's getting displayed.

Should be as simple as changing this line: https://github.com/braintree/credit-card-type/blob/401f82161e630beec72903370313898230e25cbc/lib/card-types.js#L137

Maestro will need to split that line into 2 ranges:

[500000, 504174],
// 504175 is confirmed to be only ELO cards
[504176, 506698],

Note: we're in the process of migrating this lib to Typescript, so we're unlikely to merge in any changes until that PR is complete.

gabrielozaki commented 4 years ago

Hi, I will close the issue util the Typescript migration is complete Thank you for your time and attention :smile: Gabriel Ozaki

crookedneighbor commented 4 years ago

I'm going to leave this open so we can better track it.

crookedneighbor commented 4 years ago

Typescript migration is complete.

gabrielozaki commented 4 years ago

Pull Request created https://github.com/braintree/credit-card-type/pull/111

crookedneighbor commented 4 years ago

This was released as part of v9.0.1