Capture Flow with Activities
We recommend using Capture Flow with Fragments instead of activities.
In order to use the capture flow with activities, follow these steps:
Request camera access.
Configure the capture feature using the
CaptureConfiguration
.Register an activity result handler with the
CaptureFlowContract()
.Launch the SDK with
GiniBank.startCaptureFlow()
.Handle the extraction results (e.g. in the
registerForActivityResult
).Send the final transfer summary values to Gini by calling
GiniBank.sendTransferSummary()
method which will be used to improve the future extraction accuracyClean up the SDK by calling
GiniBank.releaseCapture()
which will release the resources used by SDK.Â
Follow these recommendations:
Provide values for all necessary fields, including those that were not extracted.
Provide the final data approved by the user (and not the initially extracted only).
Send transfer summary only after TAN verification.
You don’t need to implement any extra steps.
The diagram shows the interaction between your app and the SDK:
Check out an example app to see how an integration can look like.
Gini Bank SDK returns one of the following results:
CaptureResult.Success
A document was analysed and the extractions are available in the properties of the CaptureResult.Success
object.
CaptureResult.Cancel
The user canceled Gini Bank SDK.
CaptureResult.Error
An error occurred and the details are available in the value
property of the CaptureResult.Error
object.
CaptureResult.Empty
Gini Bank SDK was able to extract information, but they were not payment related. Your app should proceed with enabling your user to enter the payment information manually.
CaptureResult.EnterManually
The document analysis finished with no results or an error and the user clicked the Enter manually button on either the No Results Screen or the Error Screen. To enable manual entry of payment information, let your app prompt users for manual input.
Learn how to launch the capture flow and handle the results from the example:
// Use the androidx's Activity Result API to register a handler for the capture result.
val captureLauncher = registerForActivityResult(CaptureFlowContract()) { result: CaptureResult ->
when (result) {
is CaptureResult.Success -> {
showExtractions(result.specificExtractions)
}
is CaptureResult.Error -> {
when (result.value) {
is ResultError.Capture -> {
val captureError: GiniCaptureError = (result.value as ResultError.Capture).giniCaptureError
handleCaptureError(captureError)
}
is ResultError.FileImport -> {
// See the File Import section on the Capture Features page for more details.
val fileImportError = result.value as ResultError.FileImport
handleFileImportError(fileImportError)
}
}
GiniBank.releaseCapture(this)
}
CaptureResult.Empty -> {
handleNoExtractions()
GiniBank.releaseCapture(this)
}
CaptureResult.Cancel -> {
handleCancellation()
GiniBank.releaseCapture(this)
}
CaptureResult.EnterManually -> {
handleEnterManually()
GiniBank.releaseCapture(this)
}
}
}
fun startGiniBankSDK() {
// Make sure camera permission has been already granted at this point.
// Instantiate the networking implementation.
val networkService: GiniCaptureNetworkService = ...
// Configure the capture feature.
GiniBank.setCaptureConfiguration(
CaptureConfiguration(
networkService = networkService,
...
)
)
// Launch and wait for the result.
GiniBank.startCaptureFlow(captureLauncher)
}
fun stopGiniBankSDKWithTransferSummary(paymentRecipient: String,
paymentReference: String,
paymentPurpose: String,
iban: String,
bic: String,
amount: Amount
) {
// After the user has seen and potentially corrected the extractions, send the final
// transfer summary values to Gini which will be used to improve the future extraction accuracy:
GiniBank.sendTransferSummary(
paymentRecipient,
paymentReference,
paymentPurpose,
iban,
bic,
amount
)
// cleanup the capture SDK after sending the transfer summary
GiniBank.releaseCapture(this)
}