A lightweight android library to scan Iranian debit cards fast and realtime using Deep Learning and TensorFlow-Lite. This library scans valid card numbers only. Keep in mind that split ABIs while releasing your app to reduce its size.
To check stability and scan speed, check STABILITY.md file.
Gradle:
dependencies {
implementation 'com.github.arefbhrn:IRDebitCardScanner:1.1.0'
}(1) Start scanner activity and wait for result:
ScanActivity.start(this)(2) Retrieve scanned data:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (ScanActivity.isScanResult(requestCode) && resultCode == Activity.RESULT_OK && data != null) {
val scanResult = ScanActivity.debitCardFromResult(data)
if (scanResult != null)
Log.d("IRDCS", scanResult.number)
}
}(1) Start scanner activity in debug mode:
ScanActivity.startDebug(this)In this mode you will see a scanned preview while scanning.
(1) Start scanner activity with alternative texts:
ScanActivity.start(this, "IRDC Scanner",
"Position your card in the frame so the card number is visible")In this mode texts in scanner activity would be set as you prefer.
DebitCardUtils provides helper methods for card validation and formatting.
Uses a Luhn check combined with a known bank prefix lookup:
val isValid = DebitCardUtils.isCardNumberValid("6104331234567890")val bankSlug = DebitCardUtils.getBankSlugFromCardNumber("6104331234567890")
// e.g. "b_mellat"val isValid = DebitCardUtils.isIbanValid("IR820540102680020817909002")Inserts a space every 4 digits:
val formatted = DebitCardUtils.format("6104331234567890")
// "6104 3312 3456 7890"Add your own 6-digit prefixes to detectable bank slugs before scanning:
DebitCardUtils.addCardNumberStarters(mapOf("123456" to "my_bank"))If you have a better idea or way on this project, please let me know. Thanks :) ?:
This project is licensed under the Apache License 2.0 - see the LICENSE file for details
