summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine A <>2024-01-16 11:28:34 +0000
committerAntoine A <>2024-01-16 11:28:34 +0000
commit11d3a68be67f8db374fa08bbfc76922c70ab40e7 (patch)
tree2d906cbaada080d5219237490d32b8f2b2662e66
parent7d3e3ea416ab8b7bc1495f8560cb41bb93013228 (diff)
downloadlibeufin-11d3a68be67f8db374fa08bbfc76922c70ab40e7.tar.gz
libeufin-11d3a68be67f8db374fa08bbfc76922c70ab40e7.tar.bz2
libeufin-11d3a68be67f8db374fa08bbfc76922c70ab40e7.zip
Add back withdrawal /abort in corebank API
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt14
-rw-r--r--bank/src/test/kotlin/CoreBankApiTest.kt4
2 files changed, 16 insertions, 2 deletions
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
index a7d0f2c6..eb39c136 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
@@ -506,6 +506,20 @@ private fun Routing.coreBankWithdrawalApi(db: Database, ctx: BankConfig) {
WithdrawalConfirmationResult.Success -> call.respond(HttpStatusCode.NoContent)
}
}
+ post("/accounts/{USERNAME}/withdrawals/{withdrawal_id}/abort") {
+ val opId = call.uuidParameter("withdrawal_id")
+ when (db.withdrawal.abort(opId)) {
+ AbortResult.UnknownOperation -> throw notFound(
+ "Withdrawal operation $opId not found",
+ TalerErrorCode.BANK_TRANSACTION_NOT_FOUND
+ )
+ AbortResult.AlreadyConfirmed -> throw conflict(
+ "Cannot abort confirmed withdrawal",
+ TalerErrorCode.BANK_ABORT_CONFIRM_CONFLICT
+ )
+ AbortResult.Success -> call.respond(HttpStatusCode.NoContent)
+ }
+ }
}
get("/withdrawals/{withdrawal_id}") {
val uuid = call.uuidParameter("withdrawal_id")
diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt b/bank/src/test/kotlin/CoreBankApiTest.kt
index 86115e78..5a031b87 100644
--- a/bank/src/test/kotlin/CoreBankApiTest.kt
+++ b/bank/src/test/kotlin/CoreBankApiTest.kt
@@ -1003,7 +1003,7 @@ class CoreBankWithdrawalApiTest {
}.assertOkJson<BankAccountCreateWithdrawalResponse> {
val uuid = it.taler_withdraw_uri.split("/").last()
withdrawalSelect(uuid)
- client.postA("/taler-integration/withdrawal-operation/$uuid/abort").assertNoContent()
+ client.postA("/accounts/merchant/withdrawals/$uuid/abort").assertNoContent()
// Check error
client.postA("/accounts/merchant/withdrawals/$uuid/confirm")
@@ -1023,7 +1023,7 @@ class CoreBankWithdrawalApiTest {
.assertConflict(TalerErrorCode.BANK_UNALLOWED_DEBIT)
// Check can abort because not confirmed
- client.postA("/taler-integration/withdrawal-operation/$uuid/abort").assertNoContent()
+ client.postA("/accounts/merchant/withdrawals/$uuid/abort").assertNoContent()
}
// Check confirm another user's operation