libeufin

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

commit fab22e862f8183e90926353d5a95b15d30b8e5f2
parent 86b3ff28ec21c6e182eefda472d02af9306cc345
Author: ms <ms@taler.net>
Date:   Sun, 19 Sep 2021 15:30:47 +0200

detect double withdraw

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -1038,16 +1038,25 @@ fun serverMain(dbName: String, port: Int) { * is as well collected in this request. */ post("/api/withdrawal-operation/{wopid}") { + val wopid: String = ensureNonNull(call.parameters["wopid"]) - logger.debug("Confirming withdraw operation: $wopid") val body = call.receiveJson<TalerWithdrawalConfirmation>() - logger.debug("Withdrawal confirmation valid.") + transaction { var wo = TalerWithdrawalEntity.find { TalerWithdrawalsTable.wopid eq UUID.fromString(wopid) }.firstOrNull() ?: throw SandboxError( HttpStatusCode.NotFound, "Withdrawal operation $wopid not found." ) + if (wo.transferDone) { + throw SandboxError( + HttpStatusCode.Conflict, + "This withdraw operation was already funded. Aborting" + ) + } + if (wo.selectionDone) { + logger.warn("This withdraw operation was already confirmed, but not funded. Trying again") + } wireTransfer( "sandbox-account-customer", "sandbox-account-exchange",