gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 04/08: sandbox payment API: ask the payment direction too


From: gnunet
Subject: [libeufin] 04/08: sandbox payment API: ask the payment direction too
Date: Fri, 04 Dec 2020 15:00:07 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 722e2cf66c171ba97b8e9fb24cbbff174dad174b
Author: MS <ms@taler.net>
AuthorDate: Fri Dec 4 12:10:43 2020 +0100

    sandbox payment API: ask the payment direction too
    
    This makes easier to understand which IBAN is the one
    managed by the Sandbox.
---
 integration-tests/tests.py                            | 19 +++++++++++++++++++
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt |  5 +++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/integration-tests/tests.py b/integration-tests/tests.py
index 262c85f..5ee3d1c 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -358,3 +358,22 @@ def test_ingestion_camt53():
     with open("camt53-gls-style-0.json") as f:
         expected_txs = f.read()
     assert not dd(resp.json(), json.loads(expected_txs), ignore_order=True)
+
+def test_sandbox_camt():
+    assertResponse(
+        post(
+            f"{S}/admin/payments/",
+            json=dict(
+                creditorIban="GB33BUKB20201555555555",
+                creditorBic="ABCXYZ",
+                creditorName="Oliver Smith",
+                debitorIban="FR00000000000000000000",
+                debitorBic="ABCXYZ",
+                debitorName="Max Mustermann",
+                amount=5,
+                currency="EUR",
+                subject="Reimbursement",
+                direction="CRDT"
+            )
+        )
+    )
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index ac88e97..15c8e4c 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -273,7 +273,7 @@ fun serverMain(dbName: String) {
                 val body = call.receive<RawPayment>()
                 val random = Random.nextLong()
                 transaction {
-                    val debitorBankAccount = 
getBankAccountFromIban(body.debitorIban).id
+                    val localIban = if (body.direction == "DBIT") 
body.debitorIban else body.creditorIban
                     BankAccountTransactionsTable.insert {
                         it[creditorIban] = body.creditorIban
                         it[creditorBic] = body.creditorBic
@@ -287,7 +287,8 @@ fun serverMain(dbName: String) {
                         it[date] = Instant.now().toEpochMilli()
                         it[pmtInfId] = random.toString()
                         it[msgId] = random.toString()
-                        it[account] = debitorBankAccount
+                        it[account] = getBankAccountFromIban(localIban).id
+                        it[direction] = body.direction
                     }
                 }
                 call.respondText("Payment created")

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