/

Observing States and Submitting Data

See VGSCollect , OnFieldStateChangeListener , VgsCollectResponseListener , VGSFileProvider , VGSRequestBuilder in API references.

Data subscribing

It allows VGSCollect to bind to the input field, retrieve user data, send requests, receive responses, and deliver it to the user.

val cardNumberField = findViewById<VGSCardNumberEditText>(R.id.cardNumberField)
vgsForm.bindView(cardNumberField)
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Tracking field states

Info
For more information about tracking states, read the developer guide.

A user can retrieve different states from a field by:

  • retrieving general state with getAllStates method in VGSCollect class.
  • observing general state with OnFieldStateChangeListener listener in VGSCollect class.
  • observing general state with OnFieldStateChangeListener listener in single secure field.
  • tracking focus by default View.OnFocusChangeListener listener for the single secure field.
  • tracking action on the editor with InputFieldView.OnEditorActionListener listener for the single secure field.

File Provider

The Collect SDK allows you to upload files to the VGS Server. VGSFileProvider may help you to manage files.

Check guide: How to manage files.

val fileProvider: VGSFileProvider = vgsForm.getFileProvider()
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Custom data

SDK provides two options to define custom user data in request: static and dynamic. Static data could be set for all requests during session. The custom data gets automatically added by VGSCollect for every request using setCustomHeaders and setCustomData methods.

In contrast, dynamic data must be set for each request.

Check guide: How to manage the Custom Data.

val data = HashMap<String, Any>()
data["nonSDKValue"] = "value"

vgsForm.setCustomData(data)
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Getting a Result from an external Activity

You can also start another activity and receive a result back. To receive a result, call startActivityForResult(). For example, your app can start a camera app and receive the credit card number as a result.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    vgsForm.onActivityResult(requestCode, resultCode, data)
}
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Submit information

Call asyncSubmit to execute and send data on VGS Server.

Collect SDK offers several ways to submit user data to Vault Proxy Serer. Here is a list of methods that can help:

val request: VGSRequest = VGSRequest.VGSRequestBuilder()
    .setMethod(HTTPMethod.POST)
    .setPath("/path")
    .build()

vgsForm.asyncSubmit(request)
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Call submit to execute and send data on VGS Server if you want to handle multithreading by yourself.

Warning
Android UI toolkit is not thread-safe. So, you must not use submit on the UI thread as this will crash.
Use asyncSubmit if a not sure in your further actions.

Handling responses

Interface definition for a callback to be invoked when VGSCollect receive response from Server.

vgsForm.addOnResponseListeners(object : VgsCollectResponseListener {
    override fun onResponse(response: VGSResponse?) {
        when(response) {
            is VGSResponse.SuccessResponse -> {
                val successCode = response.successCode
                val rawResponse = response.rawResponse
                val mapResponse = response.response
            }
            is VGSResponse.ErrorResponse -> {
                val errorCode = response.errorCode
                val localizeMessage = response.localizeMessage
            }
        }
    }
})
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

End session

Clear all information collected before by VGSCollect. Call onDestroy inside Android onDestroy callback.

override fun onDestroy() {
    vgsForm.onDestroy()
    super.onDestroy()
}
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format