首页 / IOS / iOS实现支付宝或微信扫描银行卡号信息
iOS实现支付宝或微信扫描银行卡号信息
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了iOS实现支付宝或微信扫描银行卡号信息,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含9187字,纯文字阅读大概需要14分钟。
内容图文
![iOS实现支付宝或微信扫描银行卡号信息](/upload/InfoBanner/zyjiaocheng/1138/c45242efb1844edc9fbadf0d254a5b00.jpg)
随着人的懒的助长及人的聪明程度提高,慢慢忘记笔,习惯了键盘操作或手写,慢慢我们进入扫描识别的都市里,
今天当你体验微信及支付宝扫描识别银行卡号方便准确性特别高;
github 上提供的资料有,
https://github.com/card-io/card.io-iOS-SDK
https://github.com/paypal/PayPal-iOS-SDK 等
如果是xcode5或者更新的版本,只需要添加下面的库
* AVFoundation
* AudioToolbox
* CoreMedia
* MobileCoreServices
并且保证Build Settings里面这两项都是YES:
* Enable Modules (C and Objective-C)
*Link Frameworks Automatically
2、在TARGETS-Build Settings添加 -lc++到Other Linker Flags
(3)使用
我是把它作为一个viewController类使用
代码:
导入
<code class="hljs objectivec has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: ‘Source Code Pro‘, monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#import <span class="hljs-title" style="box-sizing: border-box;">"CardIO.h"</span></span> <span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#import <span class="hljs-title" style="box-sizing: border-box;">"CardIOPaymentViewControllerDelegate.h"</span></span> - (<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span>)viewWillAppear:(<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">BOOL</span>)animated { [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">super</span> viewWillAppear:animated]; [CardIOUtilities preload]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//开始扫描</span> - (<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">IBAction</span>)scanCard:(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">id</span>)sender { CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">self</span>]; [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">self</span> presentViewController:scanViewController animated:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">YES</span> completion:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">nil</span>]; } 下面是代理方法 <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//取消扫描</span> - (<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span>)userDidCancelPaymentViewController:(CardIOPaymentViewController *)scanViewController { <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">NSLog</span>(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"User canceled payment info"</span>); <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Handle user cancellation here...</span> [scanViewController dismissViewControllerAnimated:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">YES</span> completion:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">nil</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//扫描完成</span> -(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span>)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewController:(CardIOPaymentViewController *)scanViewController { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//扫描结果</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//CardIOCreditCardInfo *info里面包含了银行卡的一些信息,如info.cardNumber是扫描的银行卡号,现实的是完整号码,而info.redactedCardNumber只显示银行卡后四位,前面的用*代替了,返回的银行卡号都没有空格</span> 可以用下面注释的方法来加空格 <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// NSString *strTem = [info.cardNumber stringByReplacingOccurrencesOfString:@" " withString:@""];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// NSString *strTem2 = @"";</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// if (strTem.length % 4 == 0)</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// {</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// int count = strTem.length / 4;</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// for (int i = 0; i < count; i++)</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// {</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// NSString *str = [strTem substringWithRange:NSMakeRange(i * 4, 4)];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// strTem2 = [strTem2 stringByAppendingString:[NSString stringWithFormat:@"%@ ", str]];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// }</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// }</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// else</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// {</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// int count = strTem.length / 4;</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// for (int j = 0; j <= count; j++)</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// {</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// if (j == count)</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// {</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// NSString *str = [strTem substringWithRange:NSMakeRange(j * 4, strTem.length % 4)];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// strTem2 = [strTem2 stringByAppendingString:[NSString stringWithFormat:@"%@ ", str]];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// }</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// else</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// {</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// NSString *str = [strTem substringWithRange:NSMakeRange(j * 4, 4)];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// strTem2 = [strTem2 stringByAppendingString:[NSString stringWithFormat:@"%@ ", str]];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// }</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// }</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// }</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">NSLog</span>(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Received card info. Number: %@, expiry: %02i/%i, cvv: %@."</span>, info<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.redactedCardNumber</span>, info<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.expiryMonth</span>, info<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.expiryYear</span>, info<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.cvv</span>); <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Use the card info...</span> [scanViewController dismissViewControllerAnimated:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">YES</span> completion:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">nil</span>]; } </code><div> </div>
原文:http://www.cnblogs.com/zero-zql/p/4729992.html
内容总结
以上是互联网集市为您收集整理的iOS实现支付宝或微信扫描银行卡号信息全部内容,希望文章能够帮你解决iOS实现支付宝或微信扫描银行卡号信息所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。