diff options
author | Antoine A <> | 2024-04-19 07:50:29 +0900 |
---|---|---|
committer | Antoine A <> | 2024-04-19 07:50:29 +0900 |
commit | fccc2eff22a0528658d6d1a42ac27e5dd2b4f34c (patch) | |
tree | 019e4e390ef9784280b21162c1becf1eef1a22a9 /nexus/src/main/kotlin/tech | |
parent | 9d8599f68e063c47eba1a9b1348f79f6357023b2 (diff) | |
download | libeufin-fccc2eff22a0528658d6d1a42ac27e5dd2b4f34c.tar.gz libeufin-fccc2eff22a0528658d6d1a42ac27e5dd2b4f34c.tar.bz2 libeufin-fccc2eff22a0528658d6d1a42ac27e5dd2b4f34c.zip |
Improve EBICS testbench
Diffstat (limited to 'nexus/src/main/kotlin/tech')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt | 2 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt | 26 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/KeyFiles.kt | 4 |
3 files changed, 19 insertions, 13 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt index ccf91594..8bde6d60 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt @@ -174,7 +174,7 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat try { submitBatch(ctx, db) } catch (e: Exception) { - throw Exception("Failed to submit payments") + throw Exception("Failed to submit payments", e) } // TODO take submitBatch taken time in the delay delay(frequency.toKotlinDuration()) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt index 124f90e4..edb53d67 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt @@ -277,12 +277,12 @@ sealed interface TxNotification { /** ISO20022 incoming payment */ data class IncomingPayment( + /** ISO20022 AccountServicerReference */ + val bankId: String, val amount: TalerAmount, val wireTransferSubject: String, - val debitPaytoUri: String, override val executionTime: Instant, - /** ISO20022 AccountServicerReference */ - val bankId: String + val debitPaytoUri: String ): TxNotification { override fun toString(): String { return "IN ${executionTime.fmtDate()} $amount '$bankId' debitor=$debitPaytoUri subject=\"$wireTransferSubject\"" @@ -291,12 +291,12 @@ data class IncomingPayment( /** ISO20022 outgoing payment */ data class OutgoingPayment( - val amount: TalerAmount, - override val executionTime: Instant, /** ISO20022 MessageIdentification */ val messageId: String, + val amount: TalerAmount, + val wireTransferSubject: String? = null, // not showing in camt.054 + override val executionTime: Instant, val creditPaytoUri: String? = null, // not showing in camt.054 - val wireTransferSubject: String? = null // not showing in camt.054 ): TxNotification { override fun toString(): String { return "OUT ${executionTime.fmtDate()} $amount '$messageId' creditor=$creditPaytoUri subject=\"$wireTransferSubject\"" @@ -349,6 +349,7 @@ fun parseTx( var msgId = opt("Refs")?.opt("MsgId")?.text() val subject = opt("RmtInf")?.map("Ustrd") { text() }?.joinToString("") var debtorPayto = opt("RltdPties") { payto("Dbtr") } + var creditorPayto = opt("RltdPties") { payto("Cdtr") } RawTx( kind, bookDate, @@ -358,7 +359,8 @@ fun parseTx( ref, msgId, subject, - debtorPayto + debtorPayto, + creditorPayto ) } } @@ -388,6 +390,7 @@ fun parseTx( var msgId = opt("Refs")?.opt("MsgId")?.text() val subject = opt("RmtInf")?.map("Ustrd") { text() }?.joinToString("") var debtorPayto = opt("RltdPties") { payto("Dbtr") } + var creditorPayto = opt("RltdPties") { payto("Cdtr") } RawTx( kind, bookDate, @@ -397,7 +400,8 @@ fun parseTx( ref, msgId, subject, - debtorPayto + debtorPayto, + creditorPayto ) } } @@ -440,7 +444,8 @@ private data class RawTx( val ref: String?, val msgId: String?, val subject: String?, - val debtorPayto: String? + val debtorPayto: String?, + val creditorPayto: String? ) private class TxErr(val msg: String): Exception(msg) @@ -478,7 +483,8 @@ private fun parseTxLogic(raw: RawTx): TxNotification { OutgoingPayment( amount = raw.amount, messageId = raw.msgId, - executionTime = raw.bookDate + executionTime = raw.bookDate, + creditPaytoUri = raw.creditorPayto ) } else -> throw Exception("Unknown transaction notification kind '${raw.kind}'") diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/KeyFiles.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/KeyFiles.kt index 172cffa2..4ea28003 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/KeyFiles.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/KeyFiles.kt @@ -118,7 +118,7 @@ fun generateNewKeys(): ClientPrivateKeysFile = submitted_ini = false ) -private inline fun <reified T> persistJsonFile(obj: T, path: Path, name: String) { +inline fun <reified T> persistJsonFile(obj: T, path: Path, name: String) { val content = try { JSON.encodeToString(obj) } catch (e: Exception) { @@ -158,7 +158,7 @@ fun persistBankKeys(keys: BankPublicKeysFile, location: Path) = persistJsonFile( fun persistClientKeys(keys: ClientPrivateKeysFile, location: Path) = persistJsonFile(keys, location, "client private keys") -private inline fun <reified T> loadJsonFile(path: Path, name: String): T? { +inline fun <reified T> loadJsonFile(path: Path, name: String): T? { val content = try { path.readText() } catch (e: Exception) { |