A network-prefix match and an issuer-metadata lookup answer different questions. A local rule can recognize a possible Visa format without knowing the issuing institution, funding type or account status. Treating those as one result creates misleading checkout messages and routing decisions.
This guide uses a deliberately fictional dataset to show where six- and eight-digit lookups become ambiguous. It does not publish a current bank directory or a list of live account ranges.
Record what the source actually knows
| Field | Evidence needed | What must not be inferred |
|---|---|---|
| Network candidate | Versioned prefix/length profile or provider response | Acceptance by your merchant account |
| Issuer or program | Maintained account-range source with defined field meaning | That a sponsor name is necessarily the brand on the card |
| Issuer country | Source definition and current record | Customer residence, billing address or current location |
| Funding category | Provider or maintained dataset value | Funding from a network prefix alone |
| Account activity or balance | Authorized provider/account interaction | Anything from Luhn or a prefix match |
Our BIN lookup reports local format candidates. It intentionally has no bank, country or funding database. The debit and credit funding demo exercises fixed mock responses, including unknown values, lookup failures and delayed responses. It accepts no card number and performs no issuer lookup; its displayed funding type comes from the selected mock. A production provider may expose richer metadata, but its unknown values and field definitions must remain visible in your data model.
Handle six and eight digits explicitly
Payment systems and datasets can use different prefix widths. A six-digit record may be broader than an eight-digit record under it. You need the source’s precision and matching semantics; “take the first six” is not a universal issuer-lookup algorithm.
Mastercard’s Simplified BIN Account Range Table is an example of an official source published for legitimate routing and related ecosystem uses. It contradicts the idea that all BIN lists are stolen data. For suspected misuse of a checkout, follow the card-fraud response guide instead of treating a prefix match as proof of abuse. Real account-range files can contain intervals and fields beyond the small prefix-only model below; implement the supplier’s schema rather than assuming this demonstration imports it.
Run a lookup that can say unknown
The fixture contains two invented labels: a broad 412345 record and a more-specific 41234567 record. Neither label names an actual institution. The function accepts only a six- or eight-digit query so the exercise does not require collecting a full PAN.
export function lookupFixtureMetadata(input, rows, today, maxAgeDays = 30) {
referenceYear(today);
if (!Number.isInteger(maxAgeDays) || maxAgeDays < 0) throw new RangeError('Invalid freshness policy');
const {status, digits} = normalizeInput(input);
if (status !== 'ok' || ![6, 8].includes(digits.length)) return {state: 'invalid-prefix'};
// A 6-digit query cannot safely choose between more-specific 8-digit children.
if (digits.length === 6 && rows.some(row => row.prefix.length === 8 && row.prefix.startsWith(digits))) {
return {state: 'needs-eight-digits'};
}
const matches = rows.filter(row => digits.startsWith(row.prefix));
if (!matches.length) return {state: 'unknown'};
const width = Math.max(...matches.map(row => row.prefix.length));
const best = matches.filter(row => row.prefix.length === width);
if (best.length !== 1) return {state: 'ambiguous'};
const row = best[0];
referenceYear(row.asOf);
const age = (Date.parse(today) - Date.parse(row.asOf)) / 86400000;
if (age < 0 || age > maxAgeDays) return {state: 'stale'};
return {state: 'matched-fixture', label: row.label, precision: width, source: row.source, asOf: row.asOf};
}| Case | Input / condition | Expected result |
|---|---|---|
| specific | Eight-digit query selects specific fictional record | {"asOf":"2026-11-01","label":"Specific fictional program","precision":8,"source":"local-fixture-v1","state":"matched-fixture"} |
| six-only | Six digits overlap a more-specific record | {"state":"needs-eight-digits"} |
| stale | Specific record is older than local 30-day policy | {"state":"stale"} |
| conflict | Two records have the same most-specific prefix | {"state":"ambiguous"} |
| unknown | Prefix absent from this tiny fictional dataset | {"state":"unknown"} |
A six-digit query overlapping an eight-digit child returns needs-eight-digits. Equal-specificity records return ambiguous, even if their labels happen to agree: importing duplicate records should be investigated. A stale specific record does not silently fall back to the broad parent, which could describe a different program.
The 30-day freshness window is a local demonstration policy, not a network rule or a vendor service commitment. The result preserves its source identifier and date. Choose a real policy from your supplier’s update schedule and the consequences of using stale data.
Keep metadata uncertainty out of customer decisions
Suppose a checkout receives unknown for funding. Turning it into credit by default changes what the application claims to know. Preserve the unknown state and use the provider’s accepted-payment-method configuration to decide the next supported action.
Likewise, a sponsor name differing from the visible card program is not automatically an erroneous record. Check whether the field means issuer, program manager or a marketing name. A country mismatch is not by itself evidence of fraud. Avoid forcing every row into a confidence score that the source never supplied.
Before replacing a dataset, compare specific matches, unresolved queries, duplicate ranges and timestamp changes. Store the dataset version alongside test results so a later update can explain a changed decision. The brand-detection guide handles local format boundaries separately.
Reproduce the examples
Extract the offline metadata examples and use Node.js 22 or later:
node guide-demo.mjs bin-metadata
node --test guide-examples.test.mjs payment-guide-examples.test.mjs
Tests cover the displayed cases plus malformed prefixes, future timestamps and the exact freshness boundary. The BIN generator can provide synthetic prefix-shaped inputs for local tests; it cannot verify that a prefix is assigned. Keep real supplier data out of a public fixture bundle unless its terms permit redistribution.
The linked Mastercard account-range reference were last checked against provider documentation on . Providers do change what they publish — the official link beside each claim is authoritative.