[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Avoid submitting payments more than on
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Avoid submitting payments more than once. |
Date: |
Mon, 16 Mar 2020 19:33:44 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 5b9bdf0 Avoid submitting payments more than once.
5b9bdf0 is described below
commit 5b9bdf0f1a14a11beb1a30de38febc085050739e
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 16 19:33:24 2020 +0100
Avoid submitting payments more than once.
---
nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt | 2 +-
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt
index 52758a7..055c67c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt
@@ -150,4 +150,4 @@ suspend fun doEbicsUploadTransaction(
throw NexusError(HttpStatusCode.InternalServerError,"unexpected
return code")
}
}
-}
+}
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index d774367..b0cca33 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -520,11 +520,11 @@ fun main() {
* should be done AFTER the PAIN.002 data corresponding to a
payment witnesses it.
*/
post("/ebics/admin/execute-payments") {
- val (painDoc: String, debtorAccount) = transaction {
+ val (paymentRowId, painDoc: String, debtorAccount) =
transaction {
val entity = Pain001Entity.find {
Pain001Table.submitted eq false
}.firstOrNull() ?: throw
NexusError(HttpStatusCode.Accepted, reason = "No ready payments found")
- kotlin.Pair(createPain001document(entity),
entity.debtorAccount)
+ Triple(entity.id, createPain001document(entity),
entity.debtorAccount)
}
logger.debug("Processing payment for bank account:
${debtorAccount}")
logger.debug("Uploading PAIN.001: ${painDoc}")
@@ -536,6 +536,14 @@ fun main() {
painDoc.toByteArray(Charsets.UTF_8),
EbicsStandardOrderParams()
)
+ /* flow here == no errors occurred */
+ transaction {
+ val payment = Pain001Entity.findById(paymentRowId) ?:
throw NexusError(
+ HttpStatusCode.InternalServerError,
+ "Severe internal error: could not find payment in DB
after having submitted it to the bank"
+ )
+ payment.submitted = true
+ }
call.respondText(
"CCT message submitted to the bank",
ContentType.Text.Plain,
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Avoid submitting payments more than once.,
gnunet <=