[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Process raw payments into Taler table.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Process raw payments into Taler table. |
Date: |
Tue, 31 Mar 2020 15:11:03 +0200 |
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 e035608 Process raw payments into Taler table.
e035608 is described below
commit e03560814c0c3e7ce0ad4056c165efce6a32c4a6
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Mar 31 15:10:42 2020 +0200
Process raw payments into Taler table.
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 24 +++++--------
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 43 +++++++++++++++++++----
2 files changed, 46 insertions(+), 21 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index c20662f..e15b295 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -12,22 +12,17 @@ import java.sql.Connection
const val ID_MAX_LENGTH = 50
-object ValidTalerIncomingPayments: LongIdTable() {
+object TalerIncomingPayments: LongIdTable() {
val payment = reference("payment", EbicsRawBankTransactionsTable)
+ val valid = bool("valid")
+ // avoid refunding twice!
+ val processed = bool("refunded").default(false)
}
-class ValidTalerIncomingPaymentEntry(id: EntityID<Long>) : LongEntity(id) {
- companion object :
LongEntityClass<ValidTalerIncomingPaymentEntry>(ValidTalerIncomingPayments)
- var payment by EbicsRawBankTransactionEntry referencedOn
ValidTalerIncomingPayments.payment
-}
-
-object InvalidTalerIncomingPayments: LongIdTable() {
- val payment = reference("payment", EbicsRawBankTransactionsTable)
-}
-
-class InvalidTalerIncomingPaymentEntry(id: EntityID<Long>) : LongEntity(id) {
- companion object :
LongEntityClass<InvalidTalerIncomingPaymentEntry>(InvalidTalerIncomingPayments)
- var payment by EbicsRawBankTransactionEntry referencedOn
InvalidTalerIncomingPayments.payment
+class TalerIncomingPaymentEntry(id: EntityID<Long>) : LongEntity(id) {
+ companion object :
LongEntityClass<TalerIncomingPaymentEntry>(TalerIncomingPayments)
+ var payment by EbicsRawBankTransactionEntry referencedOn
TalerIncomingPayments.payment
+ var valid by TalerIncomingPayments.valid
}
object EbicsRawBankTransactionsTable : LongIdTable() {
@@ -153,8 +148,7 @@ fun dbCreateTables() {
EbicsSubscribersTable,
EbicsAccountsInfoTable,
EbicsRawBankTransactionsTable,
- ValidTalerIncomingPayments,
- InvalidTalerIncomingPayments
+ TalerIncomingPayments
)
}
}
\ 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 35fc85f..3c6e179 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -39,6 +39,7 @@ import io.ktor.routing.post
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
+import net.taler.wallet.crypto.Base32Crockford
import org.apache.commons.compress.archivers.zip.ZipFile
import org.apache.commons.compress.utils.SeekableInMemoryByteChannel
import org.jetbrains.exposed.exceptions.ExposedSQLException
@@ -621,6 +622,7 @@ fun main() {
// FIXME(florian): Download C52 and store the result in the
right database table
}
+
get("/ebics/subscribers/{id}/show-collected-transactions-c53") {
val id = expectId(call.parameters["id"])
var ret = ""
@@ -633,7 +635,6 @@ fun main() {
ret += "###\nDebitor: ${it.debitorIban}\nCreditor:
${it.creditorIban}\nAmount: ${it.currency}:${it.amount}\nDate:
${it.bookingDate}\n"
}
}
-
call.respondText(
ret,
ContentType.Text.Plain,
@@ -648,11 +649,42 @@ fun main() {
* incoming transactions (those with a valid subject, i.e. a
public key),
* and invalid ones (the rest).
*/
- post("/ebics/admin/digest-incoming-transactions") {
-
+ post("/ebics/subscribers/{id}/digest-incoming-transactions") {
+ val id = expectId(call.parameters["id"])
+ // first find highest ID value of already processed rows.
+ transaction {
+ val latest =
TalerIncomingPaymentEntry.all().sortedByDescending {
+ it.payment.id
+ }.firstOrNull() ?: throw NexusError(
+ HttpStatusCode.NotFound, "No payments to process"
+ )
+ EbicsRawBankTransactionEntry.find {
+ EbicsRawBankTransactionsTable.id.greater(latest.id) and
+ (EbicsRawBankTransactionsTable.nexusSubscriber
eq id)
+ }.forEach {
+ if (CryptoUtil.checkValidEddsaPublicKey(
+
Base32Crockford.decode(it.unstructuredRemittanceInformation)
+ )
+ ) {
+ TalerIncomingPaymentEntry.new {
+ payment = it
+ valid = true
+ }
+ } else {
+ TalerIncomingPaymentEntry.new {
+ payment = it
+ valid = false
+ }
+ }
+ }
+ }
+ call.respondText (
+ "New raw payments Taler-processed",
+ ContentType.Text.Plain,
+ HttpStatusCode.OK
+ )
+ return@post
}
-
-
post("/ebics/subscribers/{id}/collect-transactions-c53") {
val id = expectId(call.parameters["id"])
val paramsJson = call.receive<EbicsStandardOrderParamsJson>()
@@ -784,7 +816,6 @@ fun main() {
}
}
}
-
post("/ebics/subscribers/{id}/sendC53") {
val id = expectId(call.parameters["id"])
val paramsJson = call.receive<EbicsStandardOrderParamsJson>()
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Process raw payments into Taler table.,
gnunet <=