[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: First steps to execute payments.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: First steps to execute payments. |
Date: |
Tue, 03 Mar 2020 21:51:33 +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 d8f6cca First steps to execute payments.
d8f6cca is described below
commit d8f6cca5b0c45cbae760308d0dfcd958d59b82d1
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Mar 3 21:51:14 2020 +0100
First steps to execute payments.
---
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 34 +++++++++++++++++++----
sandbox/src/main/python/libeufin-cli | 16 +++++++++++
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 8cf6859..5e06182 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -38,6 +38,7 @@ import io.ktor.routing.post
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
+import javafx.util.Pair
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import org.apache.commons.compress.archivers.zip.ZipFile
import org.apache.commons.compress.utils.SeekableInMemoryByteChannel
@@ -123,6 +124,12 @@ fun getBankAccountDetailsFromAcctid(id: String):
EbicsAccountInfoElement {
)
}
}
+fun getSubscriberDetailsFromBankAccount(bankAccountId: String):
EbicsClientSubscriberDetails {
+ return transaction {
+ val subscriber = EbicsAccountInfoEntity.findById(bankAccountId) ?:
throw SubscriberNotFoundError(HttpStatusCode.NotFound)
+ getSubscriberDetailsFromId(subscriber.id.value)
+ }
+}
fun getSubscriberDetailsFromId(id: String): EbicsClientSubscriberDetails {
return transaction {
@@ -537,16 +544,31 @@ fun main() {
/**
* This function triggers the Nexus to perform all those
un-submitted payments.
* Ideally, this logic will be moved into some more automatic
mechanism.
+ * NOTE: payments are not yet marked as "done" after this function
returns. This
+ * should be done AFTER the PAIN.002 data corresponding to a
payment witnesses it.
*/
post("/ebics/admin/execute-payments") {
- transaction {
- Pain001Entity.find {
+ val (painDoc, debtorAccount) = transaction {
+ val entity = Pain001Entity.find {
Pain001Table.submitted eq false
- }.forEach {
- // FIXME TODO
- }
+ }.firstOrNull() ?: throw Exception("No ready payments
found")
+ kotlin.Pair(createPain001document(entity),
entity.debtorAccount)
}
-
+ logger.info("Processing payment for bank account:
${debtorAccount}")
+ val subscriberDetails =
getSubscriberDetailsFromBankAccount(debtorAccount)
+ val response = doEbicsUploadTransaction(
+ client,
+ subscriberDetails,
+ "CCC",
+ painDoc.toByteArray(Charsets.UTF_8),
+ EbicsStandardOrderParams()
+ )
+ call.respondText(
+ response.toString(),
+ ContentType.Text.Plain,
+ HttpStatusCode.OK
+ )
+ return@post
}
post("/ebics/subscribers/{id}/fetch-payment-status") {
diff --git a/sandbox/src/main/python/libeufin-cli
b/sandbox/src/main/python/libeufin-cli
index 34b8ad6..b4e00e8 100755
--- a/sandbox/src/main/python/libeufin-cli
+++ b/sandbox/src/main/python/libeufin-cli
@@ -570,6 +570,22 @@ def prepare(ctx, account_id, nexus_base_url):
ctx.invoke(hia, account_id=account_id, nexus_base_url=nexus_base_url)
ctx.invoke(sync, account_id=account_id, nexus_base_url=nexus_base_url)
+
+@ebics.command(help="Picks the first unsubmitted payment and send it to the
bank")
+@click.pass_context
+@click.argument(
+ "nexus-base-url"
+)
+def execute_payments(ctx, nexus_base_url):
+ try:
+ url = urljoin(nexus_base_url, "/ebics/admin/execute-payments")
+ resp = post(url)
+ except Exception as e:
+ print("Could not reach the Nexus", e)
+ return
+
+ print(resp.content.decode("utf-8"))
+
@ebics.command(help="Show status of payments")
@click.pass_context
@click.option(
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: First steps to execute payments.,
gnunet <=