[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 02/03: extend bank-account API to show initiated payments sta
From: |
gnunet |
Subject: |
[libeufin] 02/03: extend bank-account API to show initiated payments status |
Date: |
Tue, 15 Dec 2020 17:51:42 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit e7175ba41286e1d71cd8a2571e25c95c58cc14b6
Author: MS <ms@taler.net>
AuthorDate: Tue Dec 15 17:38:02 2020 +0100
extend bank-account API to show initiated payments status
---
integration-tests/tests.py | 40 ++++++++++++++--------
.../main/kotlin/tech/libeufin/nexus/server/JSON.kt | 7 +++-
.../tech/libeufin/nexus/server/NexusServer.kt | 7 ++--
3 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
index ca220c0..2137184 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -120,12 +120,10 @@ def setup_function():
prepareSandbox()
prepareNexus()
-
def teardown_function():
dropSandboxTables(DB)
dropNexusTables(DB)
-
def test_env():
print("Nexus and Sandbox are up and running!")
try:
@@ -201,27 +199,39 @@ def test_payment():
)
)
PAYMENT_UUID = resp.json().get("uuid")
- assertResponse(
- post(
-
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/payment-initiations/{PAYMENT_UUID}/submit",
- json=dict(),
- auth=PERSONA.nexus.auth
- )
- )
+ assertResponse(post("/".join([
+ PERSONA.nexus.base_url,
+ "bank-accounts",
+ PERSONA.nexus.bank_label,
+ "payment-initiations",
+ PAYMENT_UUID,
+ "submit"]),
+ json=dict(),
+ auth=PERSONA.nexus.auth
+ ))
assertResponse(
post(
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/fetch-transactions",
auth=PERSONA.nexus.auth
)
)
- resp = assertResponse(
- get(
-
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/transactions",
- auth=PERSONA.nexus.auth
- )
- )
+ resp = assertResponse(get(
+
f"{PERSONA.nexus.base_url}/bank-accounts/{PERSONA.nexus.bank_label}/transactions",
+ auth=PERSONA.nexus.auth
+ ))
assert len(resp.json().get("transactions")) == 1
+ # assert now that the payment shows up as confirmed.
+ resp = assertResponse(get("/".join([
+ PERSONA.nexus.base_url,
+ "bank-accounts",
+ PERSONA.nexus.bank_label,
+ "payment-initiations",
+ PAYMENT_UUID]),
+ auth=PERSONA.nexus.auth
+ ))
+ assert resp.json()["status"] == "BOOK"
+
@pytest.fixture
def fetch_transactions():
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index ec353ab..ad11b4c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -233,7 +233,12 @@ data class PaymentStatus(
val amount: String,
val subject: String,
val submissionDate: String?,
- val preparationDate: String
+ val preparationDate: String,
+ // null when the payment was never acknowledged by
+ // the bank. For example, it was submitted but never
+ // seen in any report; or only created and not even
+ // submitted.
+ val status: EntryStatus?
)
data class Transactions(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 14fc102..e0708a7 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -575,6 +575,7 @@ fun serverMain(dbName: String, host: String) {
val sd = it.submissionDate
ret.initiatedPayments.add(
PaymentStatus(
+ status = it.confirmationTransaction?.status,
paymentInitiationId = it.id.value.toString(),
submitted = it.submitted,
creditorIban = it.creditorIban,
@@ -601,6 +602,7 @@ fun serverMain(dbName: String, host: String) {
val paymentInitiation =
getPaymentInitiation(ensureLong(call.parameters["uuid"]))
return@transaction object {
val paymentInitiation = paymentInitiation
+ val paymentStatus =
paymentInitiation.confirmationTransaction?.status
}
}
val sd = res.paymentInitiation.submissionDate
@@ -613,9 +615,8 @@ fun serverMain(dbName: String, host: String) {
creditorIban = res.paymentInitiation.creditorIban,
amount =
"${res.paymentInitiation.currency}:${res.paymentInitiation.sum}",
subject = res.paymentInitiation.subject,
- submissionDate = if (sd != null) {
- importDateFromMillis(sd).toDashedDate()
- } else null,
+ submissionDate = if (sd != null) {
importDateFromMillis(sd).toDashedDate() } else null,
+ status = res.paymentStatus,
preparationDate =
importDateFromMillis(res.paymentInitiation.preparationDate).toDashedDate()
)
)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.