Implementing Bank Card Scanning via Camera in Mobile Applications
Manual entry of 16-digit card numbers — source of typos and abandoned payment sessions. Scanning via camera solves this in 1–2 seconds. The only question is which tool to use: ready-made card OCR library or general ML framework.
Tools and Their Real Limitations
Card.io (PayPal) — historically popular library. Problem: hasn't been updated since 2018, crashes periodically on iOS 16+ at first launch due to AVCaptureSession changes. Not recommended for new projects.
Stripe CardScan / Bouncer — Stripe acquired Bouncer and open-sourced card-scan-android / card-scan-ios under Apache 2.0. This is neural network solution based on TFLite/CoreML, works offline. Recognition accuracy of card number — above 95% on standard format cards in normal lighting. On iOS connected via SPM: https://github.com/stripe/stripe-ios, on Android — via Gradle: com.stripe:stripecardscan.
Vision framework (iOS) + ML Kit (Android) — native OCR without third-party dependencies. VNRecognizeTextRequest (Vision, iOS 13+) recognizes text on image in real-time. Filter results by pattern \b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b. ML Kit Text Recognition v2 on Android works similarly via TextRecognizer.
Minus of native OCR: need to write logic for card zone detection yourself, filter false positives (random 16-digit numbers), stabilize result (confirmation via 3–5 consecutive identical results). Ready library like Bouncer does this out of the box.
What We Recognize
Card number — main goal. Expiry date (MM/YY) — Vision and ML Kit handle this. Cardholder name — OCR performs worse due to font variability and embossing. Recommendation: scan number + expiry automatically, suggest filling name manually as optional field.
Never recognize and store CVV/CVC — it's on the back, and storing it even temporarily violates PCI DSS. Scan front side only: number + expiry + optionally name.
Flutter Implementation
card_scanner pub.dev package works through Platform Channels to native SDKs. Alternative — google_mlkit_text_recognition + custom parser. For production app, prefer Bouncer SDK via FFI integration — more accurate and reliable in non-standard conditions.
Permissions and Privacy
iOS: NSCameraUsageDescription in Info.plist with clear explanation — "for card scanning during payment". Android: uses-permission android:name="android.permission.CAMERA" + runtime request via ActivityResultContracts.RequestPermission. Process frames only in memory — don't save to disk, don't send to server. Privacy-critical detail for App Store Review.
Timeline Guidelines
Bouncer/CardScan integration with basic UI (camera preview, card frame, scanning animation): 1–2 days. Custom UI + native Vision/ML Kit with own stabilization logic: 2–3 days.







