summaryrefslogtreecommitdiff
path: root/nexus/src/main/kotlin/tech/libeufin
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-06-19 00:10:52 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-06-19 00:10:52 +0530
commit3172664f1e0df86e576ade5f940886c7e01c2cd1 (patch)
treee5eb16e711279fa266ad78a123bd0bc82b16abd0 /nexus/src/main/kotlin/tech/libeufin
parentf54bd1bc9f106d18ed5b562729f701bfd50eb372 (diff)
downloadlibeufin-3172664f1e0df86e576ade5f940886c7e01c2cd1.tar.gz
libeufin-3172664f1e0df86e576ade5f940886c7e01c2cd1.tar.bz2
libeufin-3172664f1e0df86e576ade5f940886c7e01c2cd1.zip
terminology
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt4
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt43
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt13
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt4
4 files changed, 31 insertions, 33 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index a2daecf9..d3bf9c0b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -210,7 +210,7 @@ data class BankProtocolsResponse(
)
/** Request type of "POST /prepared-payments" */
-data class PreparedPaymentRequest(
+data class CreatePaymentInitiationRequest(
val iban: String,
val bic: String?,
val name: String,
@@ -219,7 +219,7 @@ data class PreparedPaymentRequest(
)
/** Response type of "POST /prepared-payments" */
-data class PreparedPaymentResponse(
+data class PaymentInitiationResponse(
val uuid: String
)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index f70cae41..46ddafab 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -246,7 +246,7 @@ fun moreFrequentBackgroundTasks(httpClient: HttpClient) {
}
// FIXME: should be done automatically after raw ingestion
reportAndIgnoreErrors { ingestTalerTransactions() }
- reportAndIgnoreErrors { submitAllPreparedPayments(httpClient) }
+ reportAndIgnoreErrors { submitAllPaymentInitiations(httpClient) }
logger.debug("More frequent background jobs done")
delay(Duration.ofSeconds(1))
}
@@ -548,53 +548,52 @@ fun serverMain(dbName: String) {
/**
* Submit one particular payment to the bank.
*/
- post("/bank-accounts/{accountid}/prepared-payments/{uuid}/submit") {
+ post("/bank-accounts/{accountid}/payment-initiations/{uuid}/submit") {
val uuid = ensureLong(call.parameters["uuid"])
val accountId = ensureNonNull(call.parameters["accountid"])
val res = transaction {
authenticateRequest(call.request)
}
- submitPreparedPayment(client, uuid)
+ submitPaymentInitiation(client, uuid)
call.respondText("Payment ${uuid} submitted")
return@post
}
/**
- * Shows information about one particular prepared payment.
+ * Shows information about one particular payment initiation.
*/
- get("/bank-accounts/{accountid}/prepared-payments/{uuid}") {
+ get("/bank-accounts/{accountid}/payment-initiations/{uuid}") {
val res = transaction {
val user = authenticateRequest(call.request)
- val preparedPayment = getPreparedPayment(ensureLong(call.parameters["uuid"]))
+ val paymentInitiation = getPaymentInitiation(ensureLong(call.parameters["uuid"]))
return@transaction object {
- val preparedPayment = preparedPayment
+ val paymentInitiation = paymentInitiation
}
}
- val sd = res.preparedPayment.submissionDate
+ val sd = res.paymentInitiation.submissionDate
call.respond(
PaymentStatus(
- paymentInitiationId = res.preparedPayment.id.value.toString(),
- submitted = res.preparedPayment.submitted,
- creditorName = res.preparedPayment.creditorName,
- creditorBic = res.preparedPayment.creditorBic,
- creditorIban = res.preparedPayment.creditorIban,
- amount = "${res.preparedPayment.currency}:${res.preparedPayment.sum}",
- subject = res.preparedPayment.subject,
+ paymentInitiationId = res.paymentInitiation.id.value.toString(),
+ submitted = res.paymentInitiation.submitted,
+ creditorName = res.paymentInitiation.creditorName,
+ creditorBic = res.paymentInitiation.creditorBic,
+ creditorIban = res.paymentInitiation.creditorIban,
+ amount = "${res.paymentInitiation.currency}:${res.paymentInitiation.sum}",
+ subject = res.paymentInitiation.subject,
submissionDate = if (sd != null) {
importDateFromMillis(sd).toDashedDate()
} else null,
- preparationDate = importDateFromMillis(res.preparedPayment.preparationDate).toDashedDate()
+ preparationDate = importDateFromMillis(res.paymentInitiation.preparationDate).toDashedDate()
)
)
return@get
}
-
/**
- * Adds a new prepared payment.
+ * Adds a new payment initiation.
*/
- post("/bank-accounts/{accountid}/prepared-payments") {
- val body = call.receive<PreparedPaymentRequest>()
+ post("/bank-accounts/{accountid}/payment-initiations") {
+ val body = call.receive<CreatePaymentInitiationRequest>()
val accountId = ensureNonNull(call.parameters["accountid"])
val res = transaction {
authenticateRequest(call.request)
@@ -603,7 +602,7 @@ fun serverMain(dbName: String) {
throw NexusError(HttpStatusCode.NotFound, "unknown bank account")
}
val amount = parseAmount(body.amount)
- val paymentEntity = addPreparedPayment(
+ val paymentEntity = addPaymentInitiation(
Pain001Data(
creditorIban = body.iban,
creditorBic = body.bic,
@@ -620,7 +619,7 @@ fun serverMain(dbName: String) {
}
call.respond(
HttpStatusCode.OK,
- PreparedPaymentResponse(uuid = res.uuid.toString())
+ PaymentInitiationResponse(uuid = res.uuid.toString())
)
return@post
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index acd128da..d35e9e63 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -32,7 +32,7 @@ import tech.libeufin.util.XMLUtil
import java.time.Instant
-suspend fun submitPreparedPayment(httpClient: HttpClient, paymentInitiationId: Long) {
+suspend fun submitPaymentInitiation(httpClient: HttpClient, paymentInitiationId: Long) {
val r = transaction {
val paymentInitiation = PaymentInitiationEntity.findById(paymentInitiationId)
if (paymentInitiation == null) {
@@ -55,7 +55,7 @@ suspend fun submitPreparedPayment(httpClient: HttpClient, paymentInitiationId: L
/**
* Submit all pending prepared payments.
*/
-suspend fun submitAllPreparedPayments(httpClient: HttpClient) {
+suspend fun submitAllPaymentInitiations(httpClient: HttpClient) {
data class Submission(
val id: Long
)
@@ -81,7 +81,7 @@ suspend fun submitAllPreparedPayments(httpClient: HttpClient) {
}
}
workQueue.forEach {
- submitPreparedPayment(httpClient, it.id)
+ submitPaymentInitiation(httpClient, it.id)
}
}
@@ -188,10 +188,9 @@ fun ingestBankMessagesIntoAccount(
}
/**
- * Retrieve prepared payment from database, raising exception
- * if not found.
+ * Retrieve payment initiation from database, raising exception if not found.
*/
-fun getPreparedPayment(uuid: Long): PaymentInitiationEntity {
+fun getPaymentInitiation(uuid: Long): PaymentInitiationEntity {
return transaction {
PaymentInitiationEntity.findById(uuid)
} ?: throw NexusError(
@@ -208,7 +207,7 @@ fun getPreparedPayment(uuid: Long): PaymentInitiationEntity {
* it will be the account whose money will pay the wire transfer being defined
* by this pain document.
*/
-fun addPreparedPayment(paymentData: Pain001Data, debitorAccount: NexusBankAccountEntity): PaymentInitiationEntity {
+fun addPaymentInitiation(paymentData: Pain001Data, debitorAccount: NexusBankAccountEntity): PaymentInitiationEntity {
return transaction {
val now = Instant.now().toEpochMilli()
val nowHex = now.toString(16)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 2b4dbc2a..3b79bac2 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -38,7 +38,7 @@ import org.jetbrains.exposed.dao.Entity
import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
-import tech.libeufin.nexus.bankaccount.addPreparedPayment
+import tech.libeufin.nexus.bankaccount.addPaymentInitiation
import tech.libeufin.util.*
import kotlin.math.abs
import kotlin.math.min
@@ -256,7 +256,7 @@ private suspend fun talerTransfer(call: ApplicationCall) {
}
}
val exchangeBankAccount = getTalerFacadeBankAccount(expectNonNull(call.parameters["fcid"]))
- val pain001 = addPreparedPayment(
+ val pain001 = addPaymentInitiation(
Pain001Data(
creditorIban = creditorData.iban,
creditorBic = creditorData.bic,