确定信用卡/借记卡类型
我正在为 iPhone/iPod 组合编写一个 POS 应用程序,使用与 Apple Stores: EasyPay 中使用的完全相同的硬件。
好的,我的障碍是:当在 uitextfield 中输入文本时,如何识别正在使用哪种信用卡类型?
我假设我必须使用 textField:shouldChangeCharactersInRange:replacementString:
?然而,我有一些想法,但我简单地无法将它们组合在一起形成代码:/
感谢任何帮助!
I'm writing a POS application for the iPhone/iPod combination, using the same exact hardware used in Apple Stores:: EasyPay.
Ok, my hurdle is this: how do I identify which credit card type is being used as text is entered in the uitextfield?
I assume I've to use textField:shouldChangeCharactersInRange:replacementString:
? However, I've got ideas floating around, but I simple cannot put them together to form code :/
Any help is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许我没有理解你的问题,但我认为你可以有一个BIN的列表(银行识别号)。例如,大多数以“4”开头的信用卡号都是 Visa。如果以“5”开头,则可能是万事达卡。这只是一个示例,您应该有一个完整的列表来识别每张可能的卡。不幸的是,完整且更新的列表是付费的,但您可以拥有一个在网络上搜索免费信息的良好列表,例如
Maybe I didn't uderstand your problem, but I think you can have a BIN's list (Bank Identification Number). For example, most credit card numbers beginning with '4' are Visa. If they begin with '5', they are probably Mastercard. This is only an example, you should have a complete list to identify each possible card. Unfortunately, a complete and updated list is paid, but you can have a good list searching for free information on the Web, like here.
您可以根据卡号的前六位数字合理猜测卡类型,这称为 发行人识别号 (IIN)
问题是,您很难获得完整的 IIN 列表。即使是主要的收购方也很难保持最新的列表,因为发行方经常添加或删除范围。
幸运的是,卡片类型通常并不重要。您应该能够对长度和luhn 校验位执行基本验证,然后提交卡到处理器进行验证和授权。
You can make a reasonable stab at guessing the card type from the first six digits of the card number, which is known as the Issuer Identification Number (IIN)
The trouble is, you'll struggle to get a complete list of IINs. Even the major acquirers struggle to keep an up to date list, as issuers frequently add or remove ranges.
Luckily, the card type shouldnt generally matter. You should be able to perform basic validation of the length, and luhn check digit, then submit the card to the processor for validation and authorization.
您可以联系 Visa/MC 并注册获取 BIN 列表更新。 Visa是免费的,但我相信MC是收费的。注册后,您将每月收到一张邮寄给您的 CD,其中包含当前的 BIN 范围。
如果您正在与处理者或 ISO(独立销售组织)合作,您也可以通过处理者或 ISO(独立销售组织)。我认为既然你有一个支付应用程序,你就与为你的客户设置商家帐户的 ISO 建立了某种关系。 ISO 应该能够从处理器处为您获取 BIN 列表,并且可能是免费的。
You can contact Visa/MC and sign up for the BIN list updates. Visa is free but I believe MC has a fee. Once you sign up, you will get a cd mailed to you with the current BIN ranges monthly.
You can also go through a processor or ISO (independent sales org) if you are working with one. I assume since you have a payment app you have some sort of relationship with an ISO that sets ups merchant accounts for your customers. The ISO should be able to get the BIN list for you from the processor and probably for free.
我认为您的
textField:shouldChangeCharactersInRange:replacementString:
走在正确的轨道上,因为每次用户更改文本字段中的内容时都会调用它。听起来您实际上并不想更改 textField,而是想更改另一个标识卡类型的相关控件。您可以使用按号码确定信用卡类型中描述的算法作为助手当用户开始打字时相应地调整信用卡类型的功能。您可能希望跳过完整验证,直到输入字符串具有正确的字符数。
更新:在同一个线程中有一个有趣的回复 提到实际上让用户选择信用卡类型是一个好主意,因为它至少向用户显示您接受的信用卡列表。
I think you are on the right track with
textField:shouldChangeCharactersInRange:replacementString:
, as this gets called each time the user changes the content in the text field. It sounds like you do not actually want to change the textField, but instead want to change another, related control that identifies the card type. You can use the algorithm described in Determine Credit Card Type By Number as a helper function to adjust credit card type accordingly when the user begins typing.You may want to skip the full verification until the input string has the correct number of characters.
Update: an interesting response in the same thread mentions that actually letting the user pick credit card type is a good idea because it at least shows the user the list of credit cards you accept.