[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: /taler/transfer reads NEXUS_PRODUCTION
From: |
gnunet |
Subject: |
[libeufin] branch master updated: /taler/transfer reads NEXUS_PRODUCTION env. |
Date: |
Wed, 15 Apr 2020 16:41:42 +0200 |
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 9ded2f3 /taler/transfer reads NEXUS_PRODUCTION env.
9ded2f3 is described below
commit 9ded2f3e02b3bd5a746fb56ae289705aa79efdfb
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Apr 15 16:38:09 2020 +0200
/taler/transfer reads NEXUS_PRODUCTION env.
If NEXUS_PRODUCTION is defined, the requests to /taler/transfer
goes through the ordinary EBICS layer; in contrast, when such env
variable is not defined, then Nexus mocks all the requests as
successful payments in its local database. In this latter case,
no bank or sandbox are required for the nexus to participate in
tests.
---
nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 88 +++++-----------------
1 file changed, 17 insertions(+), 71 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 11750a1..abb74ab 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -162,60 +162,6 @@ class Taler(app: Route) {
init {
app.post("/taler/transfer") {
- val exchangeId =
authenticateRequest(call.request.headers["Authorization"])
- val transferRequest = call.receive<TalerTransferRequest>()
- val opaque_row_id = transaction {
- val creditorData = parsePayto(transferRequest.credit_account)
- val exchangeBankAccount = getBankAccountsInfoFromId(exchangeId)
- val pain001 = createPain001entity(
- Pain001Data(
- creditorIban = creditorData.iban,
- creditorBic = creditorData.bic,
- creditorName = creditorData.name,
- subject = transferRequest.wtid,
- sum = parseAmount(transferRequest.amount).amount
- ),
- exchangeBankAccount.first().id.value
- )
- TalerRequestedPaymentEntity.find {
- TalerRequestedPayments.requestUId eq
transferRequest.request_uid
- }.forEach {
- if (
- (it.amount != transferRequest.amount) or
- (it.creditAccount !=
transferRequest.exchange_base_url) or
- (it.wtid != transferRequest.wtid)
- ) {
- throw NexusError(
- HttpStatusCode.Conflict,
- "This uid (${transferRequest.request_uid}) belongs
to a different payment already"
- )
- }
- }
- val row = TalerRequestedPaymentEntity.new {
- preparedPayment = pain001
- exchangeBaseUrl = transferRequest.exchange_base_url
- requestUId = transferRequest.request_uid
- amount = transferRequest.amount
- wtid = transferRequest.wtid
- creditAccount = transferRequest.credit_account
- }
- row.id.value
- }
- call.respond(
- HttpStatusCode.OK,
- TalerTransferResponse(
- /**
- * Normally should point to the next round where the
background
- * routine will send new PAIN.001 data to the bank; work
in progress..
- */
- timestamp = DateTime.now().millis / 1000,
- row_id = opaque_row_id
- )
- )
- return@post
- }
-
- app.post("/taler/test/transfer") {
val exchangeId =
authenticateRequest(call.request.headers["Authorization"])
val transferRequest = call.receive<TalerTransferRequest>()
val amountObj = parseAmount(transferRequest.amount)
@@ -224,7 +170,6 @@ class Taler(app: Route) {
val opaque_row_id = transaction {
val creditorData = parsePayto(transferRequest.credit_account)
val exchangeBankAccount =
getBankAccountsInfoFromId(exchangeId).first()
-
/**
* Checking the UID has the desired characteristics.
*/
@@ -252,21 +197,23 @@ class Taler(app: Route) {
),
exchangeBankAccount.id.value
)
- val rawEbics = EbicsRawBankTransactionEntity.new {
- sourceFileName = "test"
- unstructuredRemittanceInformation = transferRequest.wtid
- transactionType = "DBIT"
- currency = amountObj.currency
- amount = amountObj.amount.toPlainString()
- debitorName = "Exchange Company"
- debitorIban = exchangeBankAccount.iban
- creditorName = creditorObj.name
- creditorIban = creditorObj.iban
- counterpartBic = creditorObj.bic
- bookingDate = DateTime.now().toString("Y-MM-dd")
- nexusSubscriber = exchangeBankAccount.subscriber
- status = "BOOK"
- }
+ val rawEbics = if (System.getenv("NEXUS_PRODUCTION") == null) {
+ EbicsRawBankTransactionEntity.new {
+ sourceFileName = "test"
+ unstructuredRemittanceInformation =
transferRequest.wtid
+ transactionType = "DBIT"
+ currency = amountObj.currency
+ amount = amountObj.amount.toPlainString()
+ debitorName = "Exchange Company"
+ debitorIban = exchangeBankAccount.iban
+ creditorName = creditorObj.name
+ creditorIban = creditorObj.iban
+ counterpartBic = creditorObj.bic
+ bookingDate = DateTime.now().toString("Y-MM-dd")
+ nexusSubscriber = exchangeBankAccount.subscriber
+ status = "BOOK"
+ }
+ } else null
val row = TalerRequestedPaymentEntity.new {
preparedPayment = pain001 // not really used/needed, just
here to silence warnings
@@ -397,7 +344,6 @@ class Taler(app: Route) {
}
}
}
-
/**
* Search for fresh OUTGOING transactions acknowledged by the
bank. As well
* searching only for BOOKed transactions, even though status
changes should
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: /taler/transfer reads NEXUS_PRODUCTION env.,
gnunet <=