summaryrefslogtreecommitdiff
path: root/sandbox/src/main/kotlin/tech/libeufin
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-05-16 11:17:57 +0200
committerMS <ms@taler.net>2023-05-16 11:17:57 +0200
commit75777424f450a640998bcb7c8a7823afa5aa49f1 (patch)
tree0a1163902dbb9660efe638fc10af744a8b3e36b2 /sandbox/src/main/kotlin/tech/libeufin
parent550c2b39faaa8e4384e879b02e6ceabddf24bb36 (diff)
downloadlibeufin-75777424f450a640998bcb7c8a7823afa5aa49f1.tar.gz
libeufin-75777424f450a640998bcb7c8a7823afa5aa49f1.tar.bz2
libeufin-75777424f450a640998bcb7c8a7823afa5aa49f1.zip
fix cash-out currency
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin')
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt40
1 files changed, 20 insertions, 20 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt
index a6572b57..bbbae1df 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt
@@ -249,6 +249,19 @@ suspend fun cashoutMonitor(
val config = demobank?.config ?: throw internalServerError(
"Demobank '$demobankName' has no configuration."
)
+ /**
+ * The monitor needs the cash-out currency to correctly POST
+ * payment initiations at Nexus. Recall: Nexus bank accounts
+ * do not mandate any particular currency, as they serve as mere
+ * bridges to the backing bank. And: a backing bank may have
+ * multiple currencies, or the backing bank may not explicitly
+ * specify any currencies to be _the_ currency of the backed
+ * bank account.
+ */
+ if (config.cashoutCurrency == null) {
+ logger.error("Config lacks cash-out currency.")
+ exitProcess(1)
+ }
val nexusBaseUrl = getConfigValueOrThrow(config::nexusBaseUrl)
val usernameAtNexus = getConfigValueOrThrow(config::usernameAtNexus)
val passwordAtNexus = getConfigValueOrThrow(config::passwordAtNexus)
@@ -292,8 +305,8 @@ suspend fun cashoutMonitor(
*/
val uid = it.accountServicerReference
val iban = it.creditorIban
- val bic = it.debtorBic
- val amount = "${it.currency}:${it.amount}"
+ val bic = it.creditorBic
+ val amount = "${config.cashoutCurrency}:${it.amount}" // FIXME: need fiat currency here.
val subject = it.subject
val name = it.creditorName
}
@@ -328,20 +341,6 @@ suspend fun cashoutMonitor(
if (resp.status.value != HttpStatusCode.OK.value) {
logger.error("Cash-out monitor, unhandled response status: ${resp.status.value}. Fail Sandbox")
exitProcess(1)
-
- // Previous versions use to store the faulty transaction
- // and continue the execution. The block below shows how
- // to do that.
-
- /*transaction {
- CashoutSubmissionEntity.new {
- localTransaction = it.id
- this.hasErrors = true
- if (maybeResponseBody.isNotEmpty())
- this.maybeNexusResposnse = maybeResponseBody
- }
- bankAccount.lastFiatSubmission = it
- }*/
}
// Successful case, mark the wire transfer as submitted,
// and advance the pointer to the last submitted payment.
@@ -352,10 +351,11 @@ suspend fun cashoutMonitor(
hasErrors = false
submissionTime = resp.responseTime.timestamp
isSubmitted = true
- // Expectedly is > 0 and contains the submission
- // unique identifier _as assigned by Nexus_. Not
- // currently used by Sandbox, but may help to resolve
- // disputes.
+ /**
+ * The following block associates the submitted payment
+ * to the UID that Nexus assigned to it. It is currently not
+ * used in Sandbox, but might help for reconciliation.
+ */
if (responseBody.isNotEmpty())
maybeNexusResposnse = responseBody
}