# Card Scanner

PCI compliance during scanning is required for companies that deal with payment card information. VGS Collect SDK provides several card scan solutions for the Payment Card Industry to help protect your businesses and the sensitive information of your consumers. You can add one of the proposed card scanning solutions into your application.

**BlinkCard** - is an AI-driven credit card scanning solution\
The VGS card scanner module helps to integrate the scanner with VGSCollectSDK.

<figure><img src="https://2096104711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUreALQAfVnRMQEz110rC%2Fuploads%2Fgit-blob-3ee693bce7f0a7d8e7d54a3bec448cfb5291b705%2Fcollect-card-scan.svg?alt=media" alt=""><figcaption></figcaption></figure>

**It's required to use only the Card Scan Modules listed here, which are audited by VGS PCI requirements.**

## CardScan (BlinkCard) module <a href="#cardscan-blinkcard-module" id="cardscan-blinkcard-module"></a>

You can add a card scanning solution to your application by adding android BlinkCard adapter.

It provides a fast and easy way to scan payment cards and import them to VGS Collect. This tutorial is aimed at helping you to adapt the [BlinkCard SDK](https://github.com/blinkcard/blinkcard-android) to the VGS Collect Android SDK.

NoteWe offer already existing solution for using BlinkCard and still stay in PCI scope. Please contact with [BlinkCard team](https://github.com/blinkcard/blinkcard-android/issues) if you have any issues related to the core API of the card scanner.

See below for more information about how to integrate BlinkCard SDK into your app, and also check the latest release notes.

You can start by watching our step-by-step tutorial, in which you’ll find out how to make BlinkCard SDK a part of your Android app.

To see BlinkCard in action, check our demo app.

### Pricing <a href="#pricing" id="pricing"></a>

`BlinkCard` The module is a paid integration. Please [contact](https://microblink.com/contact-us/) Microblink for more details.

### Before you start <a href="#before-you-start" id="before-you-start"></a>

Using the BlinkCard API in your app requires a valid license. You can obtain a trial license by registering for [Microblink dashboard](https://commerce-platform-staging.blinkreceipt.com/login). After registering, you will be able to generate a license for your app. The license is bound to the package name of your app, so please make sure you enter the correct package name when asked.

### Integration <a href="#integration" id="integration"></a>

Note it is critical not to forget to import [VGS Collect](https://docs.verygoodsecurity.com/vault/developer-tools/vgs-collect/integration#integrate-vgs-collect-sdk-into-your-android-project) as well. If you’re not familiar with the VGS Collect Android SDK, we highly recommend starting from our integration documentation and following the steps in the guidelines.

In your `build.gradle` add Microblink maven repository to the repositories list.

```gradle
repositories {
    maven { url 'https://maven.microblink.com' }
}
```

Add `adapter-blinkcard` as a dependency.

```gradle
dependencies {
     implementation 'com.verygoodsecurity:vgscollect:1.7.5' // required version 1.7.5 or above
     implementation 'com.verygoodsecurity.api:adapter-blinkcard:<latest-version>'
}
```

### Configure Your App <a href="#configure-your-app" id="configure-your-app"></a>

Configure the Microblink license in `Application.onCreate` callback.

```kotlin
import android.app.Application
import com.microblink.blinkcard.MicroblinkSDK

class App: Application() {

    override fun onCreate() {
        super.onCreate()
        MicroblinkSDK.setLicenseKey("<KEY>", this)
    }
}
```

Add `VGSCardNumberEditText` to your activity XML file.

```xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    android:padding="16dp">    <com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        app:hintEnabled="true"        app:hint="Card number"        app:boxCornerRadius="4dp"        app:boxBackgroundModes="outline"        app:boxStrokeColor="#2f426f">        <com.verygoodsecurity.vgscollect.widget.VGSCardNumberEditText            android:id="@+id/cardNumber"            android:layout_width="match_parent"            android:layout_height="wrap_content"            app:fieldName="cardNumber"            app:numberDivider="-"            app:cardBrandIconGravity="end"/>    </com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout>    <Button        android:id="@+id/scanBtn"        android:text="Scan"        android:layout_marginStart="16dp"        android:layout_marginEnd="16dp"        android:layout_width="match_parent"        android:layout_height="wrap_content"/></LinearLayout>XML
```

Bind `VGSCardNumberEditText` to your `VGSCollect` object instance.

```kotlin
collect = VGSCollect(this, "tntsfeqzp4a", Environment.SANDBOX)
val cardNumberEditText = findViewById<VGSCardNumberEditText>(R.id.cardNumber)
collect.bindView(cardNumberEditText)
```

Create scanning intent using `VGSBlinkCardIntentBuilder` and link \`VGSCardNumberEditText\`\` to it. VGS Collect would automatically import received data into your input fields. For this, you need to link fields with incoming data. Use the field name to notify VGSCollect which type of incoming data it should apply to.

NoteIf you have not set it up, the VGSCollect won't receive results of scanning.KotlinJava

```kotlin
val intent = VGSBlinkCardIntentBuilder(this)
    .setCardNumberFieldName(cardNumberEditText.getFieldName())
    .build()
```

Start scanning intent for the result. After scanning the complete pass result to `VGSCollect` in `onActivityResult` callback.

```kotlin
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.verygoodsecurity.vgscollect.core.Environment
import com.verygoodsecurity.vgscollect.core.VGSCollect
import com.verygoodsecurity.api.blinkcard.VGSBlinkCardIntentBuilder
import com.verygoodsecurity.vgscollect.widget.VGSCardNumberEditText

class MainActivity : AppCompatActivity(R.layout.activity_main) {

    companion object {

        const val USER_SCAN_REQUEST_CODE = 0x7
    }

    private val collect: VGSCollect by lazy { VGSCollect(this, "tntsfeqzp4a", Environment.SANDBOX) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val cardNumberEditText = findViewById<VGSCardNumberEditText>(R.id.cardNumber)
        collect.bindView(cardNumberEditText)
        findViewById<Button>(R.id.scanBtn)?.let {
            val intent = VGSBlinkCardIntentBuilder(this)
                .setCardNumberFieldName(cardNumberEditText.getFieldName())
                .build()
            startActivityForResult(intent, USER_SCAN_REQUEST_CODE)
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        collect.onActivityResult(requestCode, resultCode, data)
    }

    override fun onDestroy() {
        collect.onDestroy()
        super.onDestroy()
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/vgs-collect/android-sdk/card-scan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
