网站如何确定信用卡号码是否有效? [英] How do websites determine if a credit card number is valid?

查看:82
本文介绍了网站如何确定信用卡号码是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览一个具有链接信用卡功能的网络应用程序,我想起了通常这些页面具有的功能,如果卡号有效,它们会立即告诉我们.他们怎么做到的?我认为没有这样的站点将请求发送到服务器以进行检查,这是在客户端完成的,但是我在JS代码中找不到任何内容.通常如何完成?

I was browsing through a web app which had functionality to link credit card, I got reminded that usually these kind of pages have a functionality where they would tell us right away if card number is valid. How do they do this? I think no such sites sends requests to the server to check this and this is done at client side but I couldn't find anything in the JS code. How this is usually done?

不是仅要求逻辑代码,Web应用程序如何检查CC是否有效?我知道前4位数字说明了公司(签证,万事达卡等),但是我没有在JS中找到任何代码,该代码表明number = XXXX是其万事达卡或类似的东西.

Am not asking for code just the logic, how do web apps check if a CC is valid or not? I know that first 4 digits tell about the company (visa, mastercard etc) but I didn't found any code in JS which said if number = XXXX its mastercard or something like this.

推荐答案

您的假设不正确.

对于初学者来说,判断信用卡是否有效的唯一方法是实际对信用卡付款.如果不与发卡行进行通信,并且交易是唯一的方式,则无法确定卡是否有效.由于在未经许可的情况下对信用卡收费永远不是一个好主意,因此最好的做法是执行称为仅授权"或仅授权"的交易,该交易会冻结信用卡的固定金额以备将来使用.建议使用0.01美元的金额,因为持卡人无法使用冻结的任何东西,直到您捕获该金额,使该交易无效或一个月后授权释放自己为止.

For starters, the only way to tell if a credit card is valid is to actually charge a payment against it. Without communicating with the card issuing bank, and a transaction is the only way to do that, it is impossible to tell if a card is valid or not. Since it is never a good idea to charge a credit card without permission it is a best practice to perform what is called an Authorization Only, or AUTH ONLY, transaction which will freeze a set amount against a credit card for future capture. Using an amount of $0.01 is recommended as anything you freeze will be unavailable to that cardholder until you either capture that amount, void that transaction, or the authorization releases itself about one month later.

通常要做的一件事是验证信用卡号是否可能有效.如果不可能或不适合进行上述详细检查,则可以基于多种因素来确定卡是否可能有效.

One thing that is common to do is verify if a credit card number is probably valid. If it is not possible, or suitable, to do the check detailed above, you can determine if a card is likely to be valid based on several factors.

  1. 该卡通过了Luhn算法
  2. BIN号有效

Luhn算法是用于验证各种标识号的简单校验和公式,例如信用卡号.有可用多种语言进行此检查的免费代码.

The Luhn algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers. There is free code available for doing this check in many languages.

银行识别码(或BIN号码)适用于Visa和MasterCard等,卡号的第一个 n 个数字将告诉您哪个银行发行了该信用卡.我知道有可用的当前BIN号码列表,您可以检查卡片是否具有有效的BIN作为预验证的一部分.

Bank Identification Numbers, or BIN numbers, apply to Visa and MasterCard among others, and the first n number of digits of the card number will tell you what bank issued that credit card. I know that there are lists available of current BIN numbers and you can check to see if a card has a valid BIN as part of your pre-validation.

如果将Luhn算法与BIN号码检查结合使用,则可以对信用卡进行预验证,并消除了许多不正确的卡的使用而无需花费任何费用.但是要100%确保存在信用卡,您必须执行交易,且仅将AUTH作为验证信用卡的正确方法.

If you combine the Luhn algorithm with BIN number checks you can do a pre-validation of credit cards and eliminate many incorrect cards from being used quickly and without expense. But to be 100% sure a credit card exists you must perform a transaction with the AUTH ONLY being the correct way to validate the card.

这篇关于网站如何确定信用卡号码是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆