libeufin

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

commit c9ae1def05eeaf25a3068699aa1f44384840b646
parent f89c9dd1461c9b5d20a1b6b900ed6548a4a89f4c
Author: Florian Dold <florian@dold.me>
Date:   Sat, 16 Jan 2021 21:27:30 +0100

sandbox: nicer API for incoming test payments

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 25+++++++++++++++++++++++++
Mutil/src/main/kotlin/JSON.kt | 12++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -355,6 +355,31 @@ fun serverMain(dbName: String, port: Int) { call.respondText("Payment created") return@post } + post("/admin/bank-accounts/{label}/simulate-incoming-transaction") { + val body = call.receive<IncomingPaymentInfo>() + // FIXME: generate nicer UUID! + val random = Random.nextLong(0, Long.MAX_VALUE) + val accountLabel = ensureNonNull(call.parameters["label"]) + transaction { + val account = getBankAccountFromLabel(accountLabel) + BankAccountTransactionsTable.insert { + it[creditorIban] = account.iban + it[creditorBic] = account.bic + it[creditorName] = account.name + it[debitorIban] = body.debtorIban + it[debitorBic] = body.debtorBic + it[debitorName] = body.debtorName + it[subject] = body.subject + it[amount] = body.amount + it[currency] = account.currency + it[date] = Instant.now().toEpochMilli() + it[pmtInfId] = random.toString() + it[msgId] = random.toString() + it[BankAccountTransactionsTable.account] = account.id + it[direction] = "CRDT" + } + } + } /** * Associates a new bank account with an existing Ebics subscriber. */ diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt @@ -44,4 +44,13 @@ data class RawPayment( val pmtInfId: String? = null, val msgId: String? = null -) -\ No newline at end of file +) + +data class IncomingPaymentInfo( + val debtorIban: String, + val debtorBic: String, + val debtorName: String, + val amount: String, + val currency: String, + val subject: String +)