Bank Transaction Linking
Overview
We provide the ability to submit a bank account transaction identifier when capturing image for a paper document of type either receipt
or invoice
.
This provides facilitates creating link between a particular document and a bank account transaction.
This is helpful if an integrating app requires the ability to display a document associated with a particular bank account transaction, or display all document associated with a particular bank account.
Linking a Bank Transaction to a Document
- Determine
documentType
of typeSensibillAPIModel.DocumentType
that User wants to associate with document before starting capture. - Determine
accountTransactionId
that User wants to associate with document before starting capture. - Initialize CaptureFlowCoordinator
with the host
UIViewController
that will be presenting the transaction linking flow. - Set
delegate
of above created instance to the hostUIViewController
. - Build
DocumentMetadata
by initializingDocumentMetadata.Builder
with one of thedocumentType
determined inStep1
, and addaccountTransactionID
determined inStep2
. - Start transaction linking flow by passing
DocumentMetadata
object created inStep 4
usingstart(metadata:)
method on instance ofCaptureFlowCoordinator
created inStep 1
- Retain instance of coordinator.
- Optionally (recommended) register a document upload observer with DocumentUploadObserver , so you can provide custom handling of various document uploading states for a generated document.
Note:
- The
result
object received as part ofCaptureFlowCoordinatorDelegate
’s delegate methodcoordinatorDidFinishCapture(_ coordinator:, result:)
contains one or moresourceId
captured as part of transaction linking flow represents a document being uploaded to Sensibill. - The bank account transaction identifier (called
accountTransactionId
) is a free-form string that supports various transaction identifiers. It can be provided by the integrator via theadd(accountTransactionID:)
method of theDocumentMetadata.Builder
object. See Monitoring Document Uploads
Example
import Sensibill
class ViewController: UIViewController {
// MARK: - Private Properties
private var captureFlowCoordinator: CaptureFlowCoordinator?
// MARK: - Private Methods
private func linkAccountTransaction() {
// Step 1
let documentType: SensibillAPIModel.DocumentType = ... // .invoice or .receipt
// Step 2
let accountTransactionID: String = ... // example: 1234
// Step 3
let coordinator = CaptureFlowCoordinator(host: self)
// Step 4
coordinator.delegate = self
// Step 5
let metadata = DocumentMetadata.Builder(documentType: documentType)
.add(accountTransactionID: accountTransactionID)
.build()
// Step 6
coordinator.start(metadata: metadata)
// Step 7
self.captureFlowCoordinator = coordinator
}
}
When launching the Receipt Capture Flow , a transaction id can be provided. If a transaction id is provided, the transaction id will be attached as metadata to any receipt object that is created as a result of the capture flow.
For reference, the following snippets would be inserted in place of the code in step 3 of the Use Receipt Capture guide.
Kotlin
val myTransaction: MyTransactionModel // Your transaction model
captureFlow.launchCaptureFlow(
captureFlowListener,
externalAccountTransactionId = myTransaction.id
)
Java
final MyTransactionModel myTransaction; // Your transaction model
captureFlow.launchCaptureFlow(
captureFlowListener,
CaptureFlowCoordinator.Companion.getDEFAULT_CONFIG()
externalAccountTransactionId = myTransaction.getId()
);
Unlinking a Bank Transaction from a Document
The following example demonstrates how to unlink transactionId associated with document by submitting edit document request to Sensibill API.
func unlinkAccountTransaction(forDocumentID documentID: String) {
do {
let content = SensibillAPIModel.DocumentContentDto()
let accountMetadata = SensibillAPIModel.AccountMetadata(
account: nil,
transactionId: ""
)
let update = SensibillAPIModel.EditDocumentRequestDto(
content: content,
accountMetadata: accountMetadata
)
try apiClient.documents.document(
update: update,
id: id
)
.execute { task in
if let result = task.result {
switch result {
case .success:
// Unlink successful.
case .failure:
// Unlink failed.
}
} else {
...
}
}
} catch {
// Unlink failed.
}
}