gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Accepting payment details from POST.


From: gnunet
Subject: [libeufin] branch master updated: Accepting payment details from POST.
Date: Tue, 18 Feb 2020 23:30:28 +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 5a874ac  Accepting payment details from POST.
5a874ac is described below

commit 5a874acbcbce6b08550073149408124a33fa7305
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Feb 18 23:29:37 2020 +0100

    Accepting payment details from POST.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt     |  3 ---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt   | 20 ++++++++++++++------
 sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt |  6 ------
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 42f4936..5404bd2 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -73,9 +73,7 @@ object Pain001Table : IntIdTableWithAmount() {
 }
 
 class Pain001Entity(id: EntityID<Int>) : IntEntity(id) {
-
     companion object : IntEntityClass<Pain001Entity>(Pain001Table)
-
     var msgId by Pain001Table.msgId
     var paymentId by Pain001Table.paymentId
     var date by Pain001Table.fileDate
@@ -89,7 +87,6 @@ class Pain001Entity(id: EntityID<Int>) : IntEntity(id) {
     var submitted by Pain001Table.submitted
 }
 
-
 object EbicsAccountsInfoTable : IdTable<String>() {
     override val id = varchar("id", ID_MAX_LENGTH).entityId().primaryKey()
     val subscriber = reference("subscriber", EbicsSubscribersTable)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 242c1ed..28e921e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -158,31 +158,28 @@ fun getSubscriberDetailsFromId(id: String): 
EbicsClientSubscriberDetails {
     }
 }
 
-data class Pain001Entry(
-    val debtorAccountId: String,
+data class Pain001Data(
     val creditorIban: String,
     val creditorBic: String,
     val creditorName: String,
     val sum: Amount,
     val subject: String
-
 )
 
 /**
  * Insert one row in the database, and leaves it marked as non-submitted.
  */
-fun createPain001entry(entry: Pain001Entry) {
+fun createPain001entry(entry: Pain001Data, debtorAccountId: String) {
     transaction {
         Pain001Entity.new {
             subject = entry.subject
             sum = entry.sum
-            debtorAccount = entry.debtorAccountId
+            debtorAccount = debtorAccountId
             creditorName = entry.creditorName
             creditorBic = entry.creditorBic
             creditorIban = entry.creditorIban
         }
     }
-
 }
 
 fun main() {
@@ -371,9 +368,20 @@ fun main() {
             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)
+                    if (accountinfo?.subscriber != subscriber) {
+                        throw Exception("Claimed account doesn't belong to 
POSTer!")
+                    }
+                }
+                val pain001data = call.receive<Pain001Data>()
+                createPain001entry(pain001data, acctid)
+
                 /**
                  * Payment preparation logic goes here!
                  */
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 32f62f9..3563dfe 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -31,9 +31,6 @@ import java.math.MathContext
 import java.math.RoundingMode
 import java.sql.Blob
 import java.sql.Connection
-import tech.libeufin.util.IntIdTableWithAmount
-
-
 
 const val CUSTOMER_NAME_MAX_LENGTH = 20
 const val EBICS_HOST_ID_MAX_LENGTH = 10
@@ -112,15 +109,12 @@ object BankTransactionsTable : IntIdTableWithAmount() {
 class BankTransactionEntity(id: EntityID<Int>) : IntEntity(id) {
 
     companion object : 
IntEntityClass<BankTransactionEntity>(BankTransactionsTable)
-
     /* the id of the local customer involved in this transaction,
     * either as the credit or the debit part; makes lookups easier */
     var localCustomer by BankCustomerEntity referencedOn 
BankTransactionsTable.localCustomer
-
     /* keeping as strings, as to allow hosting IBANs and/or other
     * unobvious formats.  */
     var counterpart by BankTransactionsTable.counterpart
-
     var subject by BankTransactionsTable.subject
     var operationDate by BankTransactionsTable.operationDate
     var valueDate by BankTransactionsTable.valueDate

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



reply via email to

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