gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: sandbox: nicer API for incoming test p


From: gnunet
Subject: [libeufin] branch master updated: sandbox: nicer API for incoming test payments
Date: Sat, 16 Jan 2021 21:27:36 +0100

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

dold pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new c9ae1de  sandbox: nicer API for incoming test payments
c9ae1de is described below

commit c9ae1def05eeaf25a3068699aa1f44384840b646
Author: Florian Dold <florian@dold.me>
AuthorDate: Sat Jan 16 21:27:30 2021 +0100

    sandbox: nicer API for incoming test payments
---
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 25 ++++++++++++++++++++++
 util/src/main/kotlin/JSON.kt                       | 11 +++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 0d682fc..9049cfb 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -355,6 +355,31 @@ fun serverMain(dbName: String, port: Int) {
                 call.respondText("Payment created")
                 return@post
             }
+            post("/admin/bank-accounts/{label}/simulate-incoming-transaction") 
{
+                val body = call.receive<IncomingPaymentInfo>()
+                // FIXME: generate nicer UUID!
+                val random = Random.nextLong(0, Long.MAX_VALUE)
+                val accountLabel = ensureNonNull(call.parameters["label"])
+                transaction {
+                    val account = getBankAccountFromLabel(accountLabel)
+                    BankAccountTransactionsTable.insert {
+                        it[creditorIban] = account.iban
+                        it[creditorBic] = account.bic
+                        it[creditorName] = account.name
+                        it[debitorIban] = body.debtorIban
+                        it[debitorBic] = body.debtorBic
+                        it[debitorName] = body.debtorName
+                        it[subject] = body.subject
+                        it[amount] = body.amount
+                        it[currency] = account.currency
+                        it[date] = Instant.now().toEpochMilli()
+                        it[pmtInfId] = random.toString()
+                        it[msgId] = random.toString()
+                        it[BankAccountTransactionsTable.account] = account.id
+                        it[direction] = "CRDT"
+                    }
+                }
+            }
             /**
              * Associates a new bank account with an existing Ebics subscriber.
              */
diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt
index a2f6c54..41c04e3 100644
--- a/util/src/main/kotlin/JSON.kt
+++ b/util/src/main/kotlin/JSON.kt
@@ -44,4 +44,13 @@ data class RawPayment(
     val pmtInfId: String? = null,
     val msgId: String? = null
 
-)
\ No newline at end of file
+)
+
+data class IncomingPaymentInfo(
+    val debtorIban: String,
+    val debtorBic: String,
+    val debtorName: String,
+    val amount: String,
+    val currency: String,
+    val subject: String
+)

-- 
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]