libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit e7175ba41286e1d71cd8a2571e25c95c58cc14b6
parent 38a83cfeed54165a9df69ac5e97d2b32260847cf
Author: MS <ms@taler.net>
Date:   Tue, 15 Dec 2020 17:38:02 +0100

extend bank-account API to show initiated payments status

Diffstat:
Mintegration-tests/tests.py | 40+++++++++++++++++++++++++---------------
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt | 7++++++-
Mnexus/src/main/kotlin/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 @@ -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 @@ -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 @@ -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() ) )