Go to file
dankito a983df42b1 Mapping BankingGroup (TODO: but is duplicated code from BankListCreator); added BankingGroup to CustomerAccountViewInfo 2024-08-27 23:36:18 +02:00
BankingClient Added description and clarified that by default the transaction of last 90 days are retrieved 2024-08-26 22:37:30 +02:00
BankingClientModel Mapping BankingGroup (TODO: but is duplicated code from BankListCreator); added BankingGroup to CustomerAccountViewInfo 2024-08-27 23:36:18 +02:00
FinTs4jBankingClient Mapping BankingGroup (TODO: but is duplicated code from BankListCreator); added BankingGroup to CustomerAccountViewInfo 2024-08-27 23:36:18 +02:00
SampleApp Added note for which plugin to use 2024-08-26 03:13:50 +02:00
gradle Added documentation 2024-08-17 03:26:11 +02:00
kotlin-js-store Had to downgrade kotlinx-datetime version as with 0.6.0 native image generation fails 2024-08-20 00:04:16 +02:00
.gitignore Added basic BankingClient model 2024-08-16 16:53:49 +02:00
.gitmodules Made banking-client-model publishable 2024-08-16 16:55:33 +02:00
README.md Added example to show the options of getAccountData() 2024-08-22 18:25:57 +02:00
build.gradle.kts Fixed project name of fints4k-banking-client 2024-08-26 03:13:09 +02:00
gradle.properties Had to downgrade kotlinx-datetime version as with 0.6.0 native image generation fails 2024-08-20 00:04:16 +02:00
gradlew Initial commit 2024-08-14 19:41:11 +02:00
gradlew.bat Initial commit 2024-08-14 19:41:11 +02:00
settings.gradle.kts Added SampleApp to show usage 2024-08-22 17:00:34 +02:00

README.md

Banking Client

Library to abstract over different banking client implementations like fints4k.

It's primary purpose is to abstract away the different implementation details and to create a common model that can be used in all projects directly or indirectly referencing it - Web Service, Middleware, Native Apps, HTML Apps - so that not each project has the implement to model again.

Setup

Gradle:

plugins {
    kotlin("jvm") version "2.0.10" // or kotlin("multiplatform"), depending on your requirements
}


repositories {
    mavenCentral()
    maven {
        setUrl("https://maven.dankito.net/api/packages/codinux/maven")
    }
}


dependencies {
    implementation("net.codinux.banking.client:fints4k-banking-client:0.5.0")
}

Usage

For the full example source code see ShowUsage.

Get AccountData

Retrieves data like accounts, balance and booked transactions (Konten, Saldo und Kontoumsätze).

Simple example:

class ShowUsage {

    private val bankCode = "" // Bankleitzahl deiner Bank

    private val loginName = "" // Online-Banking Login Name mit dem du dich beim Online-Banking deiner Bank anmeldest

    private val password = "" // Online-Banking Password mit dem du dich beim Online-Banking deiner Bank anmeldest


    fun getAccountData() {
        val client = FinTs4kBankingClientForCustomer(bankCode, loginName, password, SimpleBankingClientCallback())

        val response = client.getAccountData()

        printReceivedData(response)
    }


    private fun printReceivedData(response: Response<GetAccountDataResponse>) {
        response.data?.let { data ->
            val customer = data.customer
            println("Kunde: ${customer.customerName} ${customer.accounts.size} Konten @ ${customer.bic} ${customer.bankName}")

            println()
            println("Konten:")
            customer.accounts.sortedBy { it.type }.forEach { account ->
                println("${account.identifier} ${account.productName} ${account.balance} ${account.currency}")
            }

            println()
            println("Umsätze:")
            data.bookedTransactions.forEach { transaction ->
                println("${transaction.valueDate} ${transaction.amount} ${transaction.currency} ${transaction.otherPartyName ?: ""} - ${transaction.reference}")
            }
        }
    }
}

This fetches the booked account transactions of the last 90 days. In most cases no TAN is required for this.

In case there is, add TAN handling in Client Callback:

val client = FinTs4kBankingClientForCustomer(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
    val tan: String? = null // if a TAN is required, add a UI or ...
    callback.invoke(EnterTanResult(tan)) // ...  set a break point here, get TAN e.g. from your TAN app, set tan variable in debugger view and resume debugger
})

You can also specify options e.g. which transactions should be retrieved:

val options = GetAccountDataOptions(
    retrieveBalance = true, // retrieve balance (Saldo / Kontostand) yes or no
    retrieveTransactions = RetrieveTransactions.AccordingToRetrieveFromAndTo, // so that fromDate and toDate below determine of which time period transactions (Umsätze) should be retrieved; defaults to OfLast90Days which in most cases doesn't require a TAN
    retrieveTransactionsFrom = LocalDate(2023, 1, 1),
    retrieveTransactionsTo = LocalDate(2023, 12, 31),
    abortIfTanIsRequired = false // e.g. for command line application when entering TAN is either not possible or a TAN procedure is used that cannot be handled via a break point (e.g. showing a TAN image or flicker code)
)
val response = client.getAccountData(options)

Add some error handling by checking response.error:

response.error?.let{ error ->
    println("Could not fetch account data: ${error.internalError ?: error.errorMessagesFromBank.joinToString()}")
}