Development guide

A guide to developing the CardScan SDK and using some of its more advanced features.

Contents

Code Organization

The CardScan SDK is built from multiple android modules, each of which builds upon more base modules. The structure of the modules used in CardScan looks like this:

module structure

The CardScan SDK consists of these modules as well as a demo app:

scan-framework

The scan-framework module contains the framework used to scan images. See the architecture document for details on how it processes images from the camera.

scan-camera

The scan-camera module contains the camera interfaces for setting up the camera on the device and receiving images from it. It also handles converting the images from the camera to a processable format.

scan-payment

The scan-payment module contains the code for validating and managing payment cards.

scan-ui

The scan-ui module contains some common functionality shared between user interfaces for scanning cards. This provides the card viewfinder, debug overlay, and base scan activity.

cardscan-ui

The cardscan-ui module builds on top of the scan-ui and scan-payment modules to provide user interfaces for scanning payment cards. Anything specific to the user interface of the CardScan product lives in this library.

cardscan-demo

The cardscan-demo app provides a demonstration for launching the CardScan SDK as a separate activity and for integrating the CardScan library into an existing activity.

Building

Check out the project using git.

git clone https://github.com/getbouncer/cardscan-android

To build the project, run the following command:

./gradlew build

To create an AAR release of the app, run the following command:

./gradlew assembleRelease

This will place an AAR file in cardscan-ui/build/outputs/aar

Contributing

These libraries follow a standard github contribution flow.

  1. Create a new github feature branch

    git checkout -b <your_github_name>/<your_feature_name>
  2. Make your code changes

  3. Push your branch to origin

    git push --set-upstream origin <your_branch_name>
  4. Create a new pull request on github, and tag appropriate owners.

  5. Once you have approval, merge your branch into master and delete your feature branch from github.

Running Unit Tests

Unit tests can be run from android studio or from the command line. To execute from the command line, run the following command:

./gradlew test

Running Android Tests

Android tests can be run from android studio or from the command line. To execute from the command line, run the following command:

./gradlew connectedAndroidTest

Note that these tests require that you have an emulator running or a physical device connected to your machine via ADB.

Releasing

See the release documentation.