• 银行卡号自动识别


    1、CardIO识别

    1.1 、CaedIO SDK下载

    下载地址

    1.2、使用方法

    1、把框架整个拉进自己的工程,然后在 TARGETS => Build Phases => Link Binary With Libraries 里边分别加入下面这几个框架。

    Accelerate.framework
    MobileCoreServices.framework
    CoreMedia.framework
    AudioToolbox.framework
    AVFoundation.framework
    

    2、在TARGETS => Build Settings => Other Linker Flags 中添加 -ObjC 和 -lc++ 。

    3、在 iOS8 + 系统中使用相机需要在 Info.plist 中添加 Privacy - Camera Usage Description,并设置其值。

    4、在我们需要调用的文件中导入

    1  // 导入头文件
    2 #import "CardIO.h"
    3 #import "CardIOPaymentViewControllerDelegate.h
    4 
    5 // 遵守协议
    6 <CardIOPaymentViewControllerDelegate>

    1.3、主要方法

    1、开始扫描银行卡

    1 [CardIOUtilities preload];
    2 
    3 CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self];
    4 
    5 [self presentViewController:scanViewController animated:YES completion:nil];

    2、取消扫描

     1 // CardIOPaymentViewControllerDelegate 协议方法
     2 - (void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)paymentViewController {
     3 
     4 [[[UIAlertView alloc] initWithTitle:@"User cancelled sca" 
     5                                     message:nil  
     6                                    delegate:nil 
     7                           cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
     8 
     9 [self dismissViewControllerAnimated:YES completion:nil];
    10 }

    3、完成扫描

     1  // CardIOPaymentViewControllerDelegate 协议方法
     2     - (void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)cardInfo inPaymentViewController:(CardIOPaymentViewController *)paymentViewController {
     3 
     4         // 获取扫描结果
     5 
     6         // cardNumber 是扫描的银行卡号,显示的是完整号码,而 redactedCardNumber 只显示银行卡后四位,前面的用 * 代替了,返回的银行卡号都没有空格
     7 
     8         NSString *redactedCardNumber = cardInfo.cardNumber;     // 卡号
     9         NSUInteger expiryMonth = cardInfo.expiryMonth;          //
    10         NSUInteger expiryYear = cardInfo.expiryYear;            //
    11         NSString *cvv = cardInfo.cvv;                           // CVV 码
    12 
    13         // 显示扫描结果
    14         NSString *msg = [NSString stringWithFormat:@"Number: %@
    
     expiry: %02lu/%lu
    
     cvv: %@", [self dealCardNumber:redactedCardNumber], expiryMonth, expiryYear, cvv];
    15         [[[UIAlertView alloc] initWithTitle:@"Received card info" message:msg  delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
    16 
    17         [self dismissViewControllerAnimated:YES completion:nil];
    18     }

    4、银行卡信息处理

     1 // 对银行卡号进行每隔四位加空格处理,自定义方法
     2     - (NSString *)dealCardNumber:(NSString *)cardNumber {
     3 
     4         NSString *strTem = [cardNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
     5         NSString *strTem2 = @"";
     6 
     7         if (strTem.length % 4 == 0) {
     8 
     9             NSUInteger count = strTem.length / 4;
    10             for (int i = 0; i < count; i++) {
    11                 NSString *str = [strTem substringWithRange:NSMakeRange(i * 4, 4)];
    12                 strTem2 = [strTem2 stringByAppendingString:[NSString stringWithFormat:@"%@ ", str]];
    13             }
    14 
    15         } else {
    16 
    17             NSUInteger count = strTem.length / 4;
    18             for (int j = 0; j <= count; j++) {
    19 
    20                 if (j == count) {
    21                     NSString *str = [strTem substringWithRange:NSMakeRange(j * 4, strTem.length % 4)];
    22                     strTem2 = [strTem2 stringByAppendingString:[NSString stringWithFormat:@"%@ ", str]];
    23                 } else {
    24                     NSString *str = [strTem substringWithRange:NSMakeRange(j * 4, 4)];
    25                     strTem2 = [strTem2 stringByAppendingString:[NSString stringWithFormat:@"%@ ", str]];
    26                 }
    27             }
    28         }
    29 
    30         return strTem2;
    31     }
  • 相关阅读:
    ME51N&nbsp;ME52N创建修改采购申请…
    修改数据库表&nbsp;字段参考的数据…
    python 变量赋值,引用,初始化问题
    python 在eclipse中的中文问题
    python全局变量在 函数中 修改
    正则表达式
    matlab 笔记
    python class self thread join __init__.py
    Quora, Yahoo Answer
    分区,grub,boot.cfg,
  • 原文地址:https://www.cnblogs.com/francisblogs/p/6541474.html
Copyright © 2020-2023  润新知