gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (c5c3f3a9 -> 8d4919c1)


From: gnunet
Subject: [libeufin] branch master updated (c5c3f3a9 -> 8d4919c1)
Date: Thu, 16 Jun 2022 12:05:12 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a change to branch master
in repository libeufin.

    from c5c3f3a9 remove wrong subject
     new 726e66d8 PAIN: allow longer currency names
     new e7731fe8 longer currency names in outgoing payments
     new c7ddd3e6 disable verbose log line
     new 8d4919c1 input amounts

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt         |  2 +-
 .../tech/libeufin/nexus/bankaccount/BankAccount.kt      |  1 +
 .../kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt     |  2 +-
 .../tech/libeufin/sandbox/EbicsProtocolBackend.kt       | 17 +++++++++++++----
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt   |  3 ++-
 util/src/main/resources/xsd/pain.001.001.03.xsd         |  2 +-
 6 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 3469cc98..d2a18041 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -202,7 +202,7 @@ object PaymentInitiationsTable : LongIdTable() {
     val preparationDate = long("preparationDate")
     val submissionDate = long("submissionDate").nullable()
     val sum = amount("sum")
-    val currency = varchar("currency", length = 3).default("EUR")
+    val currency = text("currency")
     val endToEndId = text("endToEndId")
     val paymentInformationId = text("paymentInformationId")
     val instructionId = text("instructionId")
diff --git 
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 85281613..127f2c30 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -328,6 +328,7 @@ fun addPaymentInitiation(paymentData: Pain001Data, 
debtorAccount: NexusBankAccou
         val painHex = painCounter.toString(16)
         val acctHex = debtorAccount.id.value.toString(16)
         PaymentInitiationEntity.new {
+            currency = paymentData.currency
             bankAccount = debtorAccount
             subject = paymentData.subject
             sum = paymentData.sum
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
index 82b4fb95..1af5a7b2 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
@@ -62,7 +62,7 @@ private suspend inline fun HttpClient.postToBank(url: String, 
body: String): Str
             e.message ?: "Could not reach the bank"
         )
     }
-    logger.debug("Receiving: $response")
+    // logger.debug("Receiving: $response")
     return response
 }
 
diff --git 
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 97789737..4ec3af1b 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -58,7 +58,7 @@ data class PainParseResult(
     val debtorName: String,
     val debtorBic: String?,
     val subject: String,
-    val amount: Amount,
+    val amount: String,
     val currency: String,
     val pmtInfId: String,
     val msgId: String
@@ -663,9 +663,14 @@ private fun parsePain001(paymentRequest: String): 
PainParseResult {
 
                         }
                     }
+                    if (!validatePlainAmount(txDetails.amt.textContent)) {
+                        throw EbicsProcessingError(
+                            "Amount number malformed: 
${txDetails.amt.textContent}"
+                        )
+                    }
                     PainParseResult(
                         currency = txDetails.amt.getAttribute("Ccy"),
-                        amount = Amount(txDetails.amt.textContent),
+                        amount = txDetails.amt.textContent,
                         subject = txDetails.subject,
                         debtorIban = debtorIban,
                         debtorName = debtorName,
@@ -692,6 +697,10 @@ private fun handleCct(paymentRequest: String) {
     transaction {
         try {
             val bankAccount = getBankAccountFromIban(parseResult.debtorIban)
+            if (parseResult.currency != bankAccount.demoBank.currency) throw 
EbicsRequestError(
+                "[EBICS_PROCESSING_ERROR] Currency (${parseResult.currency}) 
not supported.",
+                "091116"
+            )
             BankAccountTransactionEntity.new {
                 account = bankAccount
                 demobank = bankAccount.demoBank
@@ -702,7 +711,7 @@ private fun handleCct(paymentRequest: String) {
                 debtorName = parseResult.debtorName
                 debtorBic = parseResult.debtorBic
                 subject = parseResult.subject
-                amount = parseResult.amount.toString()
+                amount = parseResult.amount
                 currency = parseResult.currency
                 date = getUTCnow().toInstant().toEpochMilli()
                 pmtInfId = parseResult.pmtInfId
@@ -723,7 +732,7 @@ private fun handleCct(paymentRequest: String) {
                     debtorName = parseResult.debtorName
                     debtorBic = parseResult.debtorBic
                     subject = parseResult.subject
-                    amount = parseResult.amount.toString()
+                    amount = parseResult.amount
                     currency = parseResult.currency
                     date = getUTCnow().toInstant().toEpochMilli()
                     pmtInfId = parseResult.pmtInfId
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 2147ca57..67c8b371 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -1191,6 +1191,7 @@ val sandboxApp: Application.() -> Unit = {
                      * return a pair, consisting of the bank account and the 
demobank
                      * hosting it.
                      */
+                    if (!validatePlainAmount(amount)) throw 
badRequest("Invalid amount: $amount")
                     transaction {
                         wireTransfer(
                             debitAccount = bankAccount,
@@ -1199,7 +1200,7 @@ val sandboxApp: Application.() -> Unit = {
                             subject = payto.message ?: throw badRequest(
                                 "'message' query parameter missing in Payto 
address"
                             ),
-                            amount = parseAmount(amount).amount.toPlainString()
+                            amount = amount
                         )
                     }
                     call.respond(object {})
diff --git a/util/src/main/resources/xsd/pain.001.001.03.xsd 
b/util/src/main/resources/xsd/pain.001.001.03.xsd
index 96a3ef2e..60cd5d71 100644
--- a/util/src/main/resources/xsd/pain.001.001.03.xsd
+++ b/util/src/main/resources/xsd/pain.001.001.03.xsd
@@ -35,7 +35,7 @@
        </xs:complexType>
        <xs:simpleType name="ActiveOrHistoricCurrencyCode">
                <xs:restriction base="xs:string">
-                       <xs:pattern value="[A-Z]{3,3}"/>
+                       <xs:pattern value="[A-Z]{3,13}"/>
                </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="AddressType2Code">

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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