gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Return status of payments.


From: gnunet
Subject: [libeufin] branch master updated: Return status of payments.
Date: Tue, 03 Mar 2020 16:13:48 +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 7cdd0d2  Return status of payments.
7cdd0d2 is described below

commit 7cdd0d203f2c43b293a32ec116a5fb8efe076137
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Mar 3 16:13:31 2020 +0100

    Return status of payments.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 15 +++++++++
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 40 +++++++++++++++++------
 2 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index 7800c4e..68f46b2 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -1,5 +1,6 @@
 package tech.libeufin.nexus
 
+import tech.libeufin.util.Amount
 import tech.libeufin.util.EbicsDateRange
 import tech.libeufin.util.EbicsOrderParams
 import tech.libeufin.util.EbicsStandardOrderParams
@@ -118,4 +119,18 @@ data class EbicsAccountInfoElement(
 
 data class EbicsAccountsInfoResponse(
     var accounts: MutableList<EbicsAccountInfoElement> = mutableListOf()
+)
+
+data class PaymentInfoElement(
+    val debtorAccount: String,
+    val creditorIban: String,
+    val creditorBic: String,
+    val creditorName: String,
+    val subject: String,
+    val sum: Amount,
+    val submitted: Boolean
+)
+
+data class PaymentsInfo(
+    var payments: MutableList<PaymentInfoElement> = mutableListOf()
 )
\ 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 85b60fc..39c3fd6 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -486,16 +486,14 @@ fun main() {
                 return@get
             }
 
-            /* need primitive that crawls the database of pending payments and 
generates PAIN.001
-            * after those.  */
-
+            /**
+             * This endpoint gathers all the data needed to create a payment 
and persists it
+             * into the database.  However, it does NOT perform the payment 
itself!
+             */
             post("/ebics/subscribers/{id}/accounts/{acctid}/prepare-payment") {
                 val acctid = expectId(call.parameters["acctid"])
                 val subscriberId = expectId(call.parameters["id"])
 
-                val accountDetails: EbicsAccountInfoElement = 
getBankAccountDetailsFromAcctid(acctid)
-                val subscriberDetails = 
getSubscriberDetailsFromId(subscriberId)
-
                 transaction {
                     val accountinfo = EbicsAccountInfoEntity.findById(acctid)
                     val subscriber = 
EbicsSubscriberEntity.findById(subscriberId)
@@ -506,15 +504,37 @@ fun main() {
                 val pain001data = call.receive<Pain001Data>()
                 createPain001entry(pain001data, acctid)
 
-
                 call.respond(NexusErrorJson("Payment instructions persisted in 
DB"))
                 return@post
-
-                // FIXME(marcello):  Put transaction in the database, generate 
PAIN.001 document
             }
 
             get("/ebics/subscribers/{id}/payments") {
-                // FIXME(marcello):  List all outgoing transfers and their 
status
+
+                val id = expectId(call.parameters["id"])
+                val ret = PaymentsInfo()
+                transaction {
+                    EbicsAccountInfoEntity.find {
+                        EbicsAccountsInfoTable.subscriber eq id
+                    }.forEach {
+                        val element = Pain001Entity.find {
+                            Pain001Table.debtorAccount eq it.id.value
+                        }.forEach {
+                            ret.payments.add(
+                                PaymentInfoElement(
+                                    debtorAccount = it.debtorAccount,
+                                    creditorIban = it.creditorIban,
+                                    creditorBic = it.creditorBic,
+                                    creditorName = it.creditorName,
+                                    subject = it.subject,
+                                    sum = it.sum,
+                                    submitted = it.submitted // whether Nexus 
processed and sent to the bank
+                                )
+                            )
+                        }
+                    }
+                }
+                call.respond(ret)
+                return@get
             }
 
             post("/ebics/subscribers/{id}/fetch-payment-status") {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]