有没有办法检测卡的类型,即借记卡或信用卡

问题描述 投票:0回答:3

当客户位于网站结帐页面时,我需要检测卡类型:借记卡或信用卡。

我正在使用该库,即 https://github.com/braintree/credit-card-type 已经确定了该卡 brand 即 Visa、Amex、Mastercard 等。但这些不提供该卡 type 信息。这可能吗?

types credit-card luhn card
3个回答
2
投票

是的,这是可能的。您需要获取与卡类型(借记卡或信用卡)相关的 BIN 列表(Bank I识别N数字)。然后,您可以将 BIN 编号(卡的前 4-9 个数字)与该列表进行比较,该列表将告诉您卡的类型。

Worldpay 和 Card Connect 等处理器可以提供此类列表。我不确定是否有费用。我找到了这个免费的,但你需要稍微修改一下才能以编程方式使用它。 这个API也声称是免费的。


0
投票

rapidapi 的另一个 api 解决方案银行卡 Bin Num Check 有 250K+ 已发行的卡类型。

只需一次 GET 请求,其中包含卡片前 6 个数字。并查看结果

{ "bin_number": 535177, "bank": "Finansbank A.S.", "scheme": "MASTERCARD", "type": "Debit", "country": "Turkey" }

0
投票

`

// Function to detect card company based on the card number's first digits
function detectCardCompany(cardNumber) {
  // Remove non-digit characters from the card number
  const cleanedCardNumber = cardNumber.replace(/\D/g, '');

  // Determine the card company based on the first digits
  const firstDigits = cleanedCardNumber.slice(0, 6); // Consider the first 6 digits

  switch (true) {
    case /^4/.test(firstDigits):
      return require(`../../assets/social/visa.png`);
    case /^5[1-5]/.test(firstDigits):
      return require(`../../assets/social/master.png`);
    case /^3[47]/.test(firstDigits):
      return require(`../../assets/social/american.png`);
    case /^6/.test(firstDigits):
      return require(`../../assets/social/discover.png`);
    case /^30[0-5]|^36|^38|^39/.test(firstDigits):
      return require(`../../assets/social/master.png`);
    case /^35(2[89]|[3-8][0-9])/.test(firstDigits):
      return require(`../../assets/social/jcb.png`);
    case /^62/.test(firstDigits):
      return require(`../../assets/social/union.png`);
    default:
      return require(`../../assets/social/visa.png`);
  }
}

`

© www.soinside.com 2019 - 2024. All rights reserved.