Android 银行卡扫描(信用卡),IOS 银行卡扫描(信用卡)
2015-09-02 15:46
615 查看
文章来自:http://blog.csdn.net/intbird
免费的信用卡扫描SDK:https://www.card.io/
1,gradle 配置
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
compile ‘com.android.support:appcompat-v7:23.0.0’
compile ‘io.card:android-sdk:5.0.1’
}
2,清单
3,代码
1,podfile
pod ‘CardIO’
2,代码
文章来自::http://blog.csdn.net/intbird
android demo:https://github.com/intbird/ANDIntbirdCardScan
IOS demo:https://github.com/intbird/IOSIntbirdCardScan
免费的信用卡扫描SDK:https://www.card.io/
Android Demo
0.上图:1,gradle 配置
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
compile ‘com.android.support:appcompat-v7:23.0.0’
compile ‘io.card:android-sdk:5.0.1’
}
2,清单
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.intbird.soft.intbirdcardscan"> <!-- Permission to vibrate - recommended, allows vibration feedback on scan --> <uses-permission android:name="android.permission.VIBRATE" /> <!-- Permission to use camera - required --> <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> <uses-feature android:name="android.hardware.camera.flash" android:required="false" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- Activities responsible for gathering payment info --> <activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" /> <activity android:name="io.card.payment.DataEntryActivity" /> </application> </manifest>
3,代码
package com.intbird.soft.intbirdcardscan; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.TextView; import io.card.payment.CardIOActivity; import io.card.payment.CreditCard; public class MainActivity extends AppCompatActivity { private final int MY_SCAN_REQUEST_CODE = 1000; private String scanResultStr = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.btn_send).setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { Intent scanIntent = new Intent(MainActivity.this, CardIOActivity.class); // customize these values to suit your needs. scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity. startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == MY_SCAN_REQUEST_CODE){ if(data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)){ CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); String cardNo = scanResult.cardNumber ; scanResultStr += cardNo +"\n"; if(scanResult.isExpiryValid()) { String extra = scanResult.expiryMonth + "\t" + scanResult.expiryYear + "\t"; scanResultStr += extra +"\n"; } if (scanResult.cvv != null) { // Never log or display a CVV String cvv = scanResult.cvv; scanResultStr += cvv +"\n"; } if (scanResult.postalCode != null) { String postCode = scanResult.postalCode; scanResultStr += postCode +"\n"; } }else{ scanResultStr = "scan cacel"; } showScanResult(scanResultStr); } } private void showScanResult(String result){ TextView textView = (TextView)findViewById(R.id.tv_cardinfo); textView.setText(result); } }
IOS Demo
0,上图1,podfile
pod ‘CardIO’
2,代码
@implementation ViewController CardIOPaymentViewController *scanViewController; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [CardIOUtilities preload]; } - (IBAction)btnSend:(id)sender { scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self]; [self presentViewController:scanViewController animated:YES completion:nil]; } -(void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)paymentViewController{ _lbCardInfo.text = @"caceled"; [scanViewController dismissViewControllerAnimated:YES completion:nil]; } -(void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)cardInfo inPaymentViewController:(CardIOPaymentViewController *)paymentViewController{ _lbCardInfo.text = [NSString stringWithFormat:@"No:%@, expiry:%lu/%lu" , cardInfo.cardNumber,cardInfo.expiryMonth,cardInfo.expiryYear]; [scanViewController dismissViewControllerAnimated:YES completion:nil]; } @end
文章来自::http://blog.csdn.net/intbird
android demo:https://github.com/intbird/ANDIntbirdCardScan
IOS demo:https://github.com/intbird/IOSIntbirdCardScan
相关文章推荐
- Android中SQLite用法
- Android中自定义属性的使用
- Android编程规范不完全指南
- Android Canvas绘图详解
- Android 4.4 Camera调试注意事项
- Android生命周期
- Android NDK开发学习(二)
- Android利用canvas画各种图形(点、直线、弧、圆、椭圆、文字、矩形、多边形、曲线、圆角矩形)
- Android studio Error:(30, 31) 错误: 程序包 不存在
- Android学习参考2
- android 学习中的一些问题记录 主要是概念问题
- Android使用SVG矢量动画(二)
- Android使用SVG矢量动画(二)
- AndroidStudio使用——如何导入jar包
- android中判断service是否运行
- Android 4.4.4 在线播放mp3文件存在的问题
- Android APK反编译就这么简单 详解(附图)
- android LinearLayout设置selector不起作用解决
- Android-本地方法与Java相互调用-自定义ProgressBar(锅炉压力监测例子)/NDK-JNI开发实例(七)
- Android Studio实用快捷键