BIN Lookup
BIN Lookup returns card metadata based on the Bank Identification Number - the first 6 to 8 digits of a card number. Use it to identify the issuing bank, card type, scheme, and country before or during payment. This enables dynamic UI decisions - such as showing the card brand logo as the customer types - and supports intelligent routing decisions when combined with MoneyHash payment flows.
Prerequisites
- SDK initialized with your account's public API key
- The BIN Lookup service must be enabled and configured on your MoneyHash account
- For flow-based routing, the
flowIdof the flow with BIN Lookup configured must be available
BinLookUpData reference
All BIN Lookup methods return a BinLookUpData object:
| Field | Type | Description |
|---|---|---|
firstSixDigits | string | First 6 digits of the card number |
brand | string | Card scheme - e.g. Visa, MasterCard, Amex |
cardType | string | null | Card type - e.g. credit, debit, prepaid |
issuer | string | null | Issuing bank name |
issuerCountry | string | null | Issuing country name |
issuerCountryCode | string | null | ISO country code of the issuing bank |
product | string | null | Card product tier - e.g. classic, gold, platinum |
Approach 1 - Dynamic BIN lookup during card entry
Trigger BIN lookup in real time as the customer types their card number. This allows you to show the card brand logo and issuer name before the card form is submitted.
The minimum required input is 8 digits. Call binLookup() without arguments - the SDK reads from the mounted card number field automatically.
cardNumber.on("changeInput", ({ length }) => {
if (length === 8) {
moneyHash.cardForm.binLookup()
.then(binLookup => {
console.log(binLookup); // BinLookUpData
// use binLookup.brand to show card logo
// use binLookup.issuer to show bank name
})
.catch(console.error);
}
});Error handling:
| Scenario | Error |
|---|---|
| Card number not found | { "code": 404, "message": "", "type": "network" } |
| Less than 8 digits | { "type": "cardValidation", "card_number": "Card number must be at least 8 digits." } |
The minimum required input is 8 digits even though the return field is named firstSixDigits. Calling BIN lookup with fewer than 8 digits returns a validation error.
Approach 2 - BIN lookup with full card data
After the customer completes the card form and you call collect(), pass the collected cardData to binLookup for a lookup against the full card number. Optionally pass a flowId to route the lookup through a specific MoneyHash payment flow.
[Add platform code tabs here]
Web (JavaScript)
// Step 1 — collect card data
const cardData = await moneyHash.cardForm.collect();
// Step 2 — BIN lookup with full card data
try {
const binLookup = await moneyHash.cardForm.binLookup({
cardData,
flowId: '<flow_id>' // optional — pass if BIN lookup is configured on a specific flow
});
console.log(binLookup); // BinLookUpData
} catch (error) {
console.error(error);
}The card form fields must be rendered and filled before calling collect(). See Collect Card Information for setup details.
Approach 3 - BIN lookup with native pay receipt
For Apple Pay payments, use binLookupByReceipt to perform a BIN lookup against the Apple Pay receipt. This supports DPAN (Device Primary Account Number) - the tokenized card used in Apple Pay and Google Pay - which standard BIN lookup cannot resolve.
try {
const binLookup = await moneyHash.binLookupByReceipt({
nativeReceiptData: applePayReceipt,
methodId: '<method_id>', // method id received from nativePayData
flowId: '<flow_id>' // optional
});
console.log(binLookup); // BinLookUpData
} catch (error) {
console.error(error);
}methodId is the method ID received from nativePayData during the Apple Pay flow. See Apple Pay for how to retrieve it.
On flowId
flowIdThe optional flowId parameter ties the BIN lookup to a specific MoneyHash payment flow. Use it when your account has multiple flows and the BIN lookup connection and routing rules are configured on a specific flow. If omitted, the lookup runs against your account's default configuration.
Updated about 1 month ago