[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Implement Sandbox transactions both si
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Implement Sandbox transactions both sides: debtor AND creditor. |
Date: |
Fri, 30 Apr 2021 11:24:23 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 0117379 Implement Sandbox transactions both sides: debtor AND
creditor.
0117379 is described below
commit 01173796d57df5db15dc12ea24238602b7a24006
Author: MS <ms@taler.net>
AuthorDate: Fri Apr 30 11:24:13 2021 +0200
Implement Sandbox transactions both sides: debtor AND creditor.
---
.../src/main/kotlin/tech/libeufin/sandbox/DB.kt | 4 +++-
.../tech/libeufin/sandbox/EbicsProtocolBackend.kt | 24 +++++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index c6add96..1cc38fd 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -271,7 +271,9 @@ object BankAccountTransactionsTable : Table() {
val direction = text("direction")
val account = reference("account", BankAccountsTable)
- override val primaryKey = PrimaryKey(pmtInfId)
+ // It can't be unique (anymore), because one table might contain
+ // the same payment twice: once as DBIT and once as CRDT.
+ // override val primaryKey = PrimaryKey(pmtInfId)
}
/**
diff --git
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 932d63f..4df1853 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -30,6 +30,7 @@ import io.ktor.util.AttributeKey
import org.apache.xml.security.binding.xmldsig.RSAKeyValueType
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.jetbrains.exposed.sql.*
+import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.statements.api.ExposedBlob
import org.jetbrains.exposed.sql.transactions.transaction
import org.slf4j.Logger
@@ -563,9 +564,30 @@ private fun handleCct(paymentRequest: String) {
it[currency] = parseResult.currency
it[date] = Instant.now().toEpochMilli()
it[pmtInfId] = parseResult.pmtInfId
- it[accountServicerReference] = "sandboxref-getRandomString(16)"
+ it[accountServicerReference] =
"sandboxref-${getRandomString(16)}"
it[direction] = "DBIT"
}
+ val maybeLocalCreditor = BankAccountEntity.find(
+ BankAccountsTable.iban eq parseResult.creditorIban
+ ).firstOrNull()
+ if (maybeLocalCreditor != null) {
+ BankAccountTransactionsTable.insert {
+ it[account] = maybeLocalCreditor.id
+ it[creditorIban] = parseResult.creditorIban
+ it[creditorName] = parseResult.creditorName
+ it[creditorBic] = parseResult.creditorBic
+ it[debtorIban] = parseResult.debtorIban
+ it[debtorName] = parseResult.debtorName
+ it[debtorBic] = parseResult.debtorBic
+ it[subject] = parseResult.subject
+ it[amount] = parseResult.amount.toString()
+ it[currency] = parseResult.currency
+ it[date] = Instant.now().toEpochMilli()
+ it[pmtInfId] = parseResult.pmtInfId
+ it[accountServicerReference] =
"sandboxref-${getRandomString(16)}"
+ it[direction] = "CRDT"
+ }
+ }
} catch (e: ExposedSQLException) {
logger.warn("Could not insert new payment into the database: ${e}")
throw EbicsRequestError(
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Implement Sandbox transactions both sides: debtor AND creditor.,
gnunet <=