Giter Club home page Giter Club logo

ios-creditcardreader's Introduction

Credit Card Reader

Build Pod Swift Package Manager SwiftUI AltSwiftUI iOS iOS

Camera based library for SwiftUI, AltSwiftUI and UIKit with lightweight and accurate credit card information detection, and fully customizable UI controls.

logo logo

Features

  • Captures through image analysis:
    • Traditional credit card number
    • Visa Quick Read card number
    • Card expiration date
  • Can discern correct information when card contains multiple dates and numbers
  • UI controls are completely customizable
  • Retry capture function before confirmation
  • Provides SwiftUI, AltSwiftUI and UIKit interfaces

Supported Version

  • Use version: iOS 13
  • Min. deployment version: iOS 11. Note: You can import into iOS 11 projects, but can only use in iOS13+ devices.

Installation

Installation can be done by either Swift Package Manager or Cocoa Pods. Depending on the UI framework you wish to support, you must select the specific dependency. Warning: Installing just the base 'CreditCardReader' pod won't produce a usable library.

SwiftUI

pod 'CreditCardReader/SwiftUI'

SPM: CreditCardReader-SwiftUI

AltSwiftUI

pod 'CreditCardReader/AltSwiftUI'

SPM: CreditCardReader-AltSwiftUI

UIKit

pod 'CreditCardReader/UIKit'

SPM: CreditCardReader-UIKit

Sample Usage

Using the credit card reader view is straightforward. You can add it directly to your view hierarchy:

var body: some View {
	...
	CreditCardReaderView { card, _ in
       // Do something with the card
    }
	...
}

Or present it in as modal:

var body: some View {
	...
	MyView()
		.sheet(isPresented: $showCardReader) {
            CreditCardReaderView { card, _ in
                // Do something with the card
            }
        }
	...
}

Customizing Navigation and UI Controls

Basic Customization

CreditCardReaderView(
	defaultNavigationBar: .init(
		titleText: "Read Card",
		closeText: "Close"),
	defaultUIControls: .init(
		instructionsText: "Align your card with the camera",
		isRetryEnabled: false)
) { card, _ in
	// Do something with the card
}

Full Customization

ZStack {
	CreditCardReaderView(
		defaultNavigationBar: nil,
		defaultUIControls: nil
	) { card, retry in
		// Do something with the card
		// or call retry if your UI supports retry
	}
	MyOverlayView()
}

AltSwiftUI

In AltSwiftUI, the reader view is named CreditCardReadView, in order to prevent Cocoa Pods submission conflicts.

CreditCardReadView { card, _ in
    // Do something with the card
}

UIKit

When using the UIKit interface, you'd instantiate the card controller this way:

CreditCardReaderViewController { card, _ in
	// Do something with the card
} onControllerClosed: {
	// Close controller if pushed or presented
}

Likewise, you have access to all UI customization options through the initializer.

Get Involved

Code Structure

Image text recognition is handled by Vision and AVFoundation frameworks. The core components for detection in dependency order are as follows:

CardCaptureView -> CreditCardImageAnalyzer

Each supported UI framework has a separate public interface with its own UI. In general, the dependency flows are the following:

CreditCardReaderView (SwiftUI target) -> CardCaptureView -> CreditCardImageAnalyzer
CreditCardReaderView (AltSwiftUI target) -> CardCaptureView -> CreditCardImageAnalyzer

Contributing

If you find any issues or ideas of new features/improvements, you can submit an issue in GitHub.

We also welcome you to contribute by submitting a pull request.

For more information, see CONTRIBUTING.

License

MIT license. You can read the LICENSE for more details.

ios-creditcardreader's People

Contributors

kevinwl02 avatar tomas-istenik-pnx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.