gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Skeleton, plus fixing comments.


From: gnunet
Subject: [libeufin] branch master updated: Skeleton, plus fixing comments.
Date: Wed, 22 Apr 2020 22:52:35 +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 e3315e0  Skeleton, plus fixing comments.
e3315e0 is described below

commit e3315e0bd654d11e98226aac5fa9b69e3391dfd1
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Apr 22 22:52:02 2020 +0200

    Skeleton, plus fixing comments.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 43 ++++++++++++++++++++--
 1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index a77361e..87f5464 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -203,11 +203,29 @@ class Taler(app: Route) {
         return Gson().toJson(body)
     }
 
-    /** Work in progress */
+    /**
+     * This function indicates whether a payment in the raw table was already 
reported
+     * by some other EBICS message.  It works for both incoming and outgoing 
payments.
+     * Basically, it tries to match all the relevant details with those from 
the records
+     * that are already stored in the local "taler" database.
+     *
+     * @param entry a new raw payment to be checked.
+     * @return true if the payment was already "seen" by the Taler layer, 
false otherwise.
+     */
     private fun duplicatePayment(entry: EbicsRawBankTransactionEntity): 
Boolean {
         return false
     }
 
+    /**
+     * This function checks whether the bank didn't accept one exchange's 
payment initiation.
+     *
+     * @param entry the raw entry to check
+     * @return true if the payment failed, false if it was successful.
+     */
+    private fun paymentFailed(entry: EbicsRawBankTransactionEntity): Boolean {
+        return false
+    }
+
     /** Attach Taler endpoints to the main Web server */
 
     init {
@@ -402,8 +420,11 @@ class Taler(app: Route) {
                             
(EbicsRawBankTransactionsTable.id.greater(latestIncomingPaymentId))
                 }.forEach {
                     if (duplicatePayment(it)) {
-                        logger.warn("A duplicate payment situation is 
happening")
-                        throw NexusError(HttpStatusCode.InternalServerError, 
"Duplicate payment situation")
+                        logger.warn("Incomint payment already seen")
+                        throw NexusError(
+                            HttpStatusCode.InternalServerError,
+                            "Incoming payment already seen"
+                        )
                     }
                     if 
(CryptoUtil.checkValidEddsaPublicKey(it.unstructuredRemittanceInformation)) {
                         TalerIncomingPaymentEntity.new {
@@ -425,8 +446,22 @@ class Taler(app: Route) {
                 val latestOutgoingPaymentId = 
TalerRequestedPaymentEntity.getLast()
                 EbicsRawBankTransactionEntity.find {
                     EbicsRawBankTransactionsTable.id greater 
latestOutgoingPaymentId and
-                            (EbicsRawBankTransactionsTable.status eq "BOOK")
+                            ( EbicsRawBankTransactionsTable.debitorIban eq  
subscriberAccount.iban)
                 }.forEach {
+                    if (paymentFailed(it)) {
+                        logger.error("Bank didn't accept one payment from the 
exchange")
+                        throw NexusError(
+                            HttpStatusCode.InternalServerError,
+                            "Bank didn't accept one payment from the exchange"
+                        )
+                    }
+                    if (duplicatePayment(it)) {
+                        logger.warn("Incomint payment already seen")
+                        throw NexusError(
+                            HttpStatusCode.InternalServerError,
+                            "Outgoing payment already seen"
+                        )
+                    }
                     var talerRequested = TalerRequestedPaymentEntity.find {
                         TalerRequestedPayments.wtid eq 
it.unstructuredRemittanceInformation
                     }.firstOrNull() ?: throw NexusError(

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



reply via email to

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