libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 50fa9ee62b22b32252885e20e7d38255caf09593
parent 84c52ec7e8a6d4d8ce3c6e9d89e1ccd207b2053e
Author: ms <ms@taler.net>
Date:   Tue, 19 Oct 2021 11:11:00 +0200

Give IBAN upon registration.

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 2++
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 3++-
Autil/src/main/kotlin/iban.kt | 12++++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt @@ -117,6 +117,7 @@ object DemobankCustomersTable : LongIdTable() { val passwordHash = text("passwordHash") val isDebit = bool("isDebit").default(false) val name = text("name").nullable() + val iban = text("iban") } class DemobankCustomerEntity(id: EntityID<Long>) : LongEntity(id) { @@ -128,6 +129,7 @@ class DemobankCustomerEntity(id: EntityID<Long>) : LongEntity(id) { var passwordHash by DemobankCustomersTable.passwordHash var isDebit by DemobankCustomersTable.isDebit var name by DemobankCustomersTable.name + var iban by DemobankCustomersTable.iban } /** diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -1120,7 +1120,7 @@ val sandboxApp: Application.() -> Unit = { CustomerInfo( username = it.username, balance = it.balance, - iban = "To Do", + iban = it.iban, name = it.name ?: throw internalServerError( "Found name-less public account, username: ${it.username}" ) @@ -1160,6 +1160,7 @@ val sandboxApp: Application.() -> Unit = { username = req.username passwordHash = CryptoUtil.hashpw(req.password) demobankConfig = demobank.id + iban = getIban() } } call.respondText("Registration successful") diff --git a/util/src/main/kotlin/iban.kt b/util/src/main/kotlin/iban.kt @@ -0,0 +1,11 @@ +package tech.libeufin.util + +fun getIban(): String { + val bankCode = "00000000" // 8 digits + val accountCodeChars = ('0'..'9') + // 10 digits + val accountCode = (0..9).map { + accountCodeChars.random() + }.joinToString("") + return "EU00" + bankCode + accountCode +} +\ No newline at end of file