Skip to content

verygoodsecurity/vgs-collect-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,257 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UT license

VGS Collect SDK

VGS Collect - is a product suite that allows customers to collect information securely without possession of it. VGS Collect Android SDK allows you to securely collect data from your users via forms without having to have that data pass through your systems. The form fields behave like traditional input fields while securing access to the unsecured data.

Table of contents

VGS Collect Android SDK StatesVGS Collect Android SDK Response

AI Agent Integration

This repository ships a public AI skill at skills/vgs-collect-android-guide/SKILL.md for teams integrating VGSCollectSDK into Android applications.

Recommended: install the skill with skills.sh. This is the easiest way to give a compatible AI agent repository-specific guidance for VGSCollectSDK integration work.

The installed skill bundle includes references/AGENTS.md, which is the canonical durable integration guide for this SDK.

What the skill is useful for:

  • matching guidance to the installed vgscollect version when that version can be detected
  • steering integrations toward correct secure field setup, scanning, file upload, and submission flows
  • enforcing non-empty vault configuration, state.isValid validation gates, and post-upload cleanFiles() cleanup
  • preserving redaction-safe logging and analytics toggling guidance
  • following upgrade and testing rules in references/AGENTS.md

Install the skill with skills.sh:

npx skills add https://github.com/verygoodsecurity/vgs-collect-android --skill vgs-collect-android-guide

If your AI tool does not support skills yet, load skills/vgs-collect-android-guide/references/AGENTS.md directly.

Minimal System Prompt Example:

You are an autonomous engineering agent integrating the VGS Collect Android SDK into an existing Kotlin app.
Use skills/vgs-collect-android-guide/references/AGENTS.md as the authoritative policy.
Constraints:
- Only public, non-deprecated APIs.
- No raw sensitive data in logs/tests.
- Validate all fields before submission.
- Clean files after successful upload.
Goals:
1. Add a secure card form (number, name, exp, cvc) with redacted logging.
2. Integrate BlinkCard scanning.
3. Provide unit tests for valid/invalid card + expiration edge case.
Return: Modified Kotlin source files only, no secrets.

Developer Prompt (Inline Example for a Single Task):

Task: Add a custom payment card brand "mycard" (BIN starts with 7777) and ensure CVC field adapts.
Follow skills/vgs-collect-android-guide/references/AGENTS.md.
Do not break existing brand detection; add tests for detection and negative near-miss.

Structure

  • VGSCollect SDK - provides an API for interacting with the VGS Vault
  • Card Scanner - This module is for adapting blinkcard-android SDK with VGS Collect Android SDK.
  • app - sample application to act as the host app for testing the SDK during development

Integration

For integration you need to install the Android Studio and a JDK on your machine.

Integrate the VGS Collect SDK to your project.
If you are using Maven, add the following to your build.gradle file.
dependencies {
    implementation "androidx.appcompat:appcompat:<version>"
    implementation "com.google.android.material:material:<version>"

    implementation "com.verygoodsecurity:vgscollect:<latest-version>"
}
Add input fields to R.layout.activity_main layout file .
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:hint="Card number"
        app:boxCornerRadius="8dp"
        app:boxBackgroundModes="outline">

        <com.verygoodsecurity.vgscollect.widget.VGSCardNumberEditText
            android:id="@+id/cardNumberField"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="8dp"
            app:fieldName="cardNumber"
            app:numberDivider="-"
            app:cardBrandIconGravity="end"/>

    </com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout>

//Other fields..

</LinearLayout>
To initialize VGSCollect you have to set your vault id and Environment type.
You can find more information at the following section.
class MainActivity : AppCompatActivity() {
  private lateinit var vgsForm:VGSCollect

  override fun onCreate(savedInstanceState: Bundle?) {
     super.onCreate(savedInstanceState)
     setContentView(R.layout.activity_main)

     vgsForm = VGSCollect(this, "<vauilt_id>", Environment.SANDBOX)

     val view = findViewById<VGSCardNumberEditText>(R.id.cardNumberField)
     vgsForm.bindView(view)
    // Bind other fields

  }

  override fun onDestroy() {
      vgsForm.onDestroy()
      super.onDestroy()
  }
}
Fields state tracking.
When an object of this type is attached to a VGS secure field, its methods will be called when the text or focus is changed.
class MainActivity : AppCompatActivity() {
  private lateinit var vgsForm:VGSCollect

  override fun onCreate(savedInstanceState: Bundle?) {
     super.onCreate(savedInstanceState)
     setContentView(R.layout.activity_main)

     vgsForm = VGSCollect(this, "<vauilt_id>", Environment.SANDBOX)
     vgsForm.addOnFieldStateChangeListener(
     	object : OnFieldStateChangeListener {
         override fun onStateChange(state: FieldState) {
            // Handle input fields states
         }
     })

     val view = findViewById<VGSCardNumberEditText>(R.id.cardNumberField)
     view?.setOnFieldStateChangeListener(
     	object : OnFieldStateChangeListener {
         override fun onStateChange(state: FieldState) {
            // Handle single field states
         }
     })
     vgsForm.bindView(cardNumberField)
    // Bind other fields

  }

  override fun onDestroy() {
     vgsForm.onDestroy()
     super.onDestroy()
  }
}
Send a simple request. Receive responses.
Call asyncSubmit to execute and send data on VGS Server.
To retrieve response you need to implement VgsCollectResponseListener .
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    vgsForm = VGSCollect(this, "<vauilt_id>", Environment.SANDBOX)

    val submitBtn = findViewById<Button>(R.id.submitBtn)
    submitBtn?.setOnClickListener {
        submitData()
    }

    val view = findViewById<VGSCardNumberEditText>(R.id.cardNumberField)
    view.bindView(cardNumberField)
    // Bind other fields

    val submitBtn = findViewById<Button>(R.id.submitBtn)
    submitBtn?.setOnClickListener {
        vgsForm.asyncSubmit("/post", HTTPMethod.POST)
    }

    vgsForm.addOnResponseListeners(
    	object : VgsCollectResponseListener {
        override fun onResponse(response: VGSResponse?) {
            when(response) {
                is VGSResponse.SuccessResponse -> {
                    val successCode = response.successCode
                    val rawResponse = response.rawResponse
                }
                is VGSResponse.ErrorResponse -> {
                    val errorCode = response.errorCode
                    val localizeMessage = response.localizeMessage
                }
            }
        }
    })
}

Next steps

Check out documentation guides:

For a quick start, try our Demo application.

License

VGSCollect Android SDK is released under the MIT license. See LICENSE for details.