...
In order to use the capture flow, you need tofollow 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.
Clean up the SDK by calling
GiniBank.releaseCapture()
while also providing the required extraction feedback to improve future extraction accuracy. Follow the recommendations below:
...
Info |
---|
Check out the example app to see how an integration could look like. |
The Gini Bank SDK can return returns one of the following results:
CaptureResult.Success
...
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, allow your app to prompt users for manual input.
...
In the following example, you can see Learn how to launch the capture flow and how to handle the results from the example below:
Code Block | ||
---|---|---|
| ||
// 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 -> { handleExtractions(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, "", "", "", "", "", Amount.EMPTY ) } CaptureResult.Empty -> { handleNoExtractions() GiniBank.releaseCapture( this, "", "", "", "", "", Amount.EMPTY ) } CaptureResult.Cancel -> { handleCancellation() GiniBank.releaseCapture( this, "", "", "", "", "", Amount.EMPTY ) } CaptureResult.EnterManually -> { handleEnterManually() GiniBank.releaseCapture( this, "", "", "", "", "", Amount.EMPTY ) } } } fun launchGiniCapture() { // Make sure camera permission has been already granted at this point. // Check that the device fulfills the requirements. val report = GiniCaptureRequirements.checkRequirements((Context) this) if (!report.isFulfilled()) { handleUnfulfilledRequirements(report) return } // 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) } void stopGiniBankSDK() { // After the user has seen and potentially corrected the extractions // cleanup the SDK while passing in the final extraction values // which will be used as feedback to improve the future extraction accuracy: GiniBank.releaseCapture(this, paymentRecipient, paymentReference, paymentPurpose, iban, bic, amount ) } |