Credit Card NFC Reader


Source link: https://github.com/pro100svitlo/Credit-Card-NFC-Reader

Credit Card NFC Reader

This library helps developer to read data from credit card: card number, expired date, card type.
Works only with cards that has paypass or paywave technology!

  1. Demo
  2. Screenshots
  3. Usage
  4. Callbacks
  5. Proguard
  6. Updates
  7. Used In
  8. Questions and help
  9. License

Screenshots

Usage

Add the dependencies to your gradle file:
 dependencies {

compile 'com.github.pro100svitlo:creditCardNfcReader:1.0.3'
  
}
Inside your Manifest:
 <uses-permission android:name="android.permission.NFC" />
  <application

...

>

<activity

 ...

 //activity that will start when nfc scan new tag

 >

 <intent-filter>

  <action android:name="android.nfc.action.TECH_DISCOVERED" />

  <category android:name="android.intent.category.DEFAULT" />

 </intent-filter>

 <meta-data

  android:name="android.nfc.action.TECH_DISCOVERED"

  android:resource="@xml/nfc_tech_filter" />

</activity>
Add the xml file 'nfc_tech_filter':
 <resources >

 <tech-list>

  <tech>android.nfc.tech.IsoDep</tech>

 </tech-list>
  </resources>
Inside your activity or fragment:
 @Override
  protected void onCreate(Bundle savedInstanceState) {

  ...

mNfcAdapter = NfcAdapter.getDefaultAdapter(this);

if (mNfcAdapter == null){

 //do something if there are no nfc module on device

}
 else {

 //do something if there are nfc module on device

  mCardNfcUtils = new CardNfcUtils(this);

 //next few lines here needed in case you will scan credit card when app is closed

 mIntentFromCreate = true;

 onNewIntent(getIntent());

}

  
}

  ...
  @Override
  protected void onResume() {

super.onResume();

mIntentFromCreate = false;

if (mNfcAdapter != null && !mNfcAdapter.isEnabled()){

 //show some turn on nfc dialog here. take a look in the samle ;-)

}
 else if (mNfcAdapter != null){

 mCardNfcUtils.enableDispatch();

}

  
}

  ...
  @Override
  public void onPause() {

super.onPause();

if (mNfcAdapter != null) {

 mCardNfcUtils.disableDispatch();

}

  
}

  ...
  @Override
  protected void onNewIntent(Intent intent) {

super.onNewIntent(intent);

if (mNfcAdapter != null && mNfcAdapter.isEnabled()) {

 //this - interface for callbacks

 //intent = intent :)

 //mIntentFromCreate - boolean flag, for understanding if onNewIntent() was called from onCreate or not

 mCardNfcAsyncTask = new CardNfcAsyncTask.Builder(this, intent, mIntentFromCreate)

.build();

}

  
}

That's pretty much all what you need to start the work!


Callbacks:

This is the main callback for managing:

 @Override
  public void startNfcReadCard() {

//notify user that scannig start
  
}

@Override
  public void cardIsReadyToRead() {

String card = mCardNfcAsyncTask.getCardNumber();

String expiredDate = mCardNfcAsyncTask.getCardExpireDate();

String cardType = mCardNfcAsyncTask.getCardType();

  
}

@Override
  public void doNotMoveCardSoFast() {

//notify user do not move the card
  
}

@Override
  public void unknownEmvCard() {

//notify user that current card has unnown nfc tag
  
}

@Override
  public void cardWithLockedNfc() {

//notify user that current card has locked nfc tag
  
}

@Override
  public void finishNfcReadCard() {

//notify user that scannig finished
  
}

Proguard

If you are using Proguard, please add this line to your proguard-rules.pro file

-keep class com.noveogroup.android.log.** {
 *; 
}
 

Updates

  • v.1.0.0
    1. Add Ingdirect Bank visa card (Australian Bank)
    2. Add default card type as UNKNOWN. If you receive such card type, please see this;

Questions and help

If you have some problems with using this library or something doesn't work correctly - just write me an email and describe your question or problem. I will try to do my best to help you and fix the problem if it is. Here is my email: [email protected]

Used in

Please, let me know ( [email protected]) if you use this library and also please provide me with the link on googlePlay :) Thanks!

  1. SendUa
  2. PayHub

License

The MIT License (MIT)

Copyright (c) 2016 Credit Card NFC Reader

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Resources

A TextView that can get word in it's content by click, and you can set HighlightText also.

A layout that implemented ripple effect for transition animation.

Android view that allows the user to create drawings. Customize settings like color, width or tools. Undo or redo actions.

A Sun Baby LoadingView.

Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices.

Yet another MVP library. Super simple, but with enough functionality.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes