A credit card reader and parser for iOS Using Native Vision/VisionKit

Overview

iOS SPM compatible License Swift 5.0

card-reader-ios

A credit card reader and parser for iOS Using Native Vision/VisionKit

May-14-2021.00-43-17.mp4

Instructions

  • Hold camera up to a card and stay still until it gets recoginized and a picture gets taken.
  • Hit Save, and the results should get processed.

Usage as Framework

There are 2 options to present:

Simply navigate to or present CardResultsView as a sheet or View:

var body: some View {
	CardFormView(colors: [.green, .blue, .black], completion: { cardDetails in 
        print("Card Number:\n\(cardDetails.number ?? "")")
        print("Expiry Date:\n\(cardDetails.expiryDate ?? "")")
        print("Name:\n\(cardDetails.name ?? "")")
        print("Name:\n\(cardDetails.cvcNumber ?? "")")
        print("Card Type:\n\(cardDetails.type.rawValue)")
        print("Card Industry:\n\(cardDetails.industry.rawValue)")
    })
}

Only the card reader view:

Add this code in your SwiftUI Main View underneath your main StackView/ScrollView/NavigationView:

.sheet(isPresented: $isShowingSheet) {
    CardReaderView() { cardDetails in
        self.cardDetails = cardDetails
        isShowingSheet.toggle()
    }
    .edgesIgnoringSafeArea(.all)
}

Create two state variables to handle sheet presentation and to hold the card details result from the closure:

@State private var isShowingSheet = false
@State private var cardDetails: CardDetails?

Add the UI Presentation logic of the CardDetails however you see fit:

if let cardDetails = cardDetails {
    Text("Card Number:\n\(cardDetails.number ?? "")")
    Text("Expiry Date:\n\(cardDetails.expiryDate ?? "")")
    Text("Name:\n\(cardDetails.name ?? "")")
    Text("Card Type:\n\(cardDetails.type.rawValue)")
    Text("Card Industry:\n\(cardDetails.industry.rawValue)")
}

Finally, present the CardReaderView by toggling the sheet (preferably from the closure of a button action):

Button { isShowingSheet.toggle() } label: { Text("Tap to Start Credit Card reading!") } 

Notes

  • I will continue to maintain this repo and keep adding new features.
  • If you see a bug or have an idea for a new feature, please raise an issue or pull request :)

License

CardReader is available under the MIT license. See the LICENSE file for more info.

You might also like...
Accept credit cards and PayPal in your iOS app
Accept credit cards and PayPal in your iOS app

Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themse

Bank Card Generator with Swift using SnapKit DSL 💳
Bank Card Generator with Swift using SnapKit DSL 💳

iCard BankCard & CreditCard generator with Swift 3 using SnapKit DSL iCard is a simple tool for generate Credit & Bank Card , it represent cards as UI

A study card application built with SwiftUI and Combine
A study card application built with SwiftUI and Combine

StudyCards Description A study card application. I built this application to get

A Payment Card UI & Validator for iOS
A Payment Card UI & Validator for iOS

Description Caishen provides an easy-to-use text field to ask users for payment card information and to validate the input. It serves a similar purpos

SwiftUI BusinessCard - Created iOS Business card app to practice SwiftUI
SwiftUI BusinessCard - Created iOS Business card app to practice SwiftUI

SwiftUI_BusinessCard Created iOS Business card app to practice SwiftUI

Welcome Busines Card Built With Swift
Welcome Busines Card Built With Swift

BusinessCard Welcome Busines Card Main screen Contacts screen More info screen

A card viewer demo for Idolmaster Millionlive Theater Days written in Swift UI
A card viewer demo for Idolmaster Millionlive Theater Days written in Swift UI

Misaki Gallery A Millionlive's cards gallery to demostrate Swift UI. All api and

Code1System Card Moudle

Code1CardLib Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation Code1

Wizards-pal - Life counter for card games,built with swift
Wizards-pal - Life counter for card games,built with swift

Life counter for card games Made this app in the weekend to help ma boys with ht

Releases(1.2.3)
  • 1.2.3(May 14, 2021)

  • 1.2.1(May 13, 2021)

  • 1.2.0(May 12, 2021)

  • 1.1.0(May 8, 2021)

    Now supporting SwiftUI since those Views can easily be used in a UIHostingViewController and support UIKit as well. Bumped down the minimum iOS version to 13.0 and Xcode version of 12.4 with Swift 5.

    https://user-images.githubusercontent.com/37077623/117522179-dab5ff80-af7f-11eb-86eb-55291a0b3120.mp4

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(May 7, 2021)

    The first release that supports iOS 13.0 and Swift 5 running on Xcode 12.4.

    https://user-images.githubusercontent.com/37077623/117316116-4c922a00-ae56-11eb-9f54-a5e7ce8c5902.mov

    Source code(tar.gz)
    Source code(zip)
Owner
Khalid Asad
iOS Swift Mobile Application Developer
Khalid Asad
Easy to use iOS library with components for input of Credit Card data.

AnimatedCardInput This library allows you to drop into your project two easily customisable, animated components that will make input of Credit Card i

Netguru 39 Oct 16, 2022
Easily integrate Credit Card payments module in iOS App. Swift 4.0

MFCard Buy me a coffee MFCard is an awesome looking Credit Card input & validation control. Written in Swift 3. YOoo, Now MFCard is on Swift 5. Swift

MobileFirst 362 Nov 29, 2022
CreditCardForm is iOS framework that allows developers to create the UI which replicates an actual Credit Card.

CreditCardForm CreditCardForm is iOS framework that allows developers to create the UI which replicates an actual Credit Card. Fixed typo use CreditCa

Orazz 1.4k Dec 15, 2022
A credit card scanner for iOS written in Swift

DGCardScanner A credit card scanner Requirements iOS 13.0+ Swift 5.5+ Xcode 10.0+ Installation SPM File > Add Packages > https://github.com/donggyushi

donggyu 9 Jun 24, 2022
Debit/Credit card validation port of the Luhn Algorithm in Swift

SwiftLuhn Warning! This repository is no longer maintained. This is a port of the Luhn Algorithm, generally used for validating debit/credit card deta

Max Kramer 135 Sep 9, 2022
Luhn Credit Card Validation Algorithm

Luhn Algorithm This is a port of the Luhn Algorithm, generally used for validating Credit Card details, to Objective-C (iOS). Swift port can be found

Max Kramer 127 Nov 27, 2022
TextFieldFormatter - Simple Text Formatter (Credit Card Number, Phone Number, Serial Number etc.)

TextFieldFormatter Simple Text Formatter (Credit Card Number, Phone Number, Seri

Anıl ORUÇ 4 Apr 4, 2022
Luhn Credit Card Validation Algorithm

Luhn Algorithm This is a port of the Luhn Algorithm, generally used for validating Credit Card details, to Objective-C (iOS). Swift port can be found

Max Kramer 127 Nov 27, 2022
Ios-card-transition - iOS CocoaPod to create beautiful card transitions

CSCardTransition CSCardTransition is a small library allowing you to create wond

Creastel 12 Oct 31, 2022
Card Decks is a small utility application for your iPhone, iPod touch and iPad which brings you simple, configurable, colored, multi-line text cards that are grouped into card decks

Card Decks is a small utility application for your iPhone, iPod touch and iPad which brings you simple, configurable, colored, multi-line text cards that are grouped into card decks.

Arne Harren 40 Nov 24, 2022