summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine A <>2024-01-04 23:26:23 +0000
committerAntoine A <>2024-01-04 23:26:23 +0000
commit01eafe1f9d53f7d9150dfa8ea69afc92eb1afa3d (patch)
tree1308d5cbd2ef148219d76b8c0116280ae50160c7
parent9346766e1ad82b90f1a498ff526ee2908691e41f (diff)
downloadlibeufin-01eafe1f9d53f7d9150dfa8ea69afc92eb1afa3d.tar.gz
libeufin-01eafe1f9d53f7d9150dfa8ea69afc92eb1afa3d.tar.bz2
libeufin-01eafe1f9d53f7d9150dfa8ea69afc92eb1afa3d.zip
New error codes
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt4
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt1
-rw-r--r--bank/src/test/kotlin/BankIntegrationApiTest.kt1
-rw-r--r--bank/src/test/kotlin/CoreBankApiTest.kt6
-rw-r--r--database-versioning/libeufin-bank-procedures.sql1
-rw-r--r--util/src/main/kotlin/TalerErrorCode.kt44
6 files changed, 35 insertions, 22 deletions
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
index d8f00ca7..6e5fadec 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
@@ -693,7 +693,7 @@ private fun Routing.coreBankTanApi(db: Database, ctx: BankConfig) {
when (res) {
TanSolveResult.NotFound -> throw notFound(
"Challenge $id not found",
- TalerErrorCode.BANK_TRANSACTION_NOT_FOUND // TODO specific EC
+ TalerErrorCode.BANK_CHALLENGE_NOT_FOUND
)
TanSolveResult.BadCode -> throw conflict(
"Incorrect TAN code",
@@ -706,7 +706,7 @@ private fun Routing.coreBankTanApi(db: Database, ctx: BankConfig) {
)
TanSolveResult.Expired -> throw conflict(
"Challenge expired",
- TalerErrorCode.BANK_TAN_CHALLENGE_FAILED // TODO specific EC
+ TalerErrorCode.BANK_TAN_CHALLENGE_EXPIRED
)
is TanSolveResult.Success -> when (res.op) {
Operation.account_reconfig -> {
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt b/bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt
index 46693bec..5f8b2f8e 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt
@@ -68,7 +68,6 @@ class WithdrawalDAO(private val db: Database) {
/** Abort withdrawal operation [uuid] */
suspend fun abort(uuid: UUID): AbortResult = db.serializable { conn ->
- // TODO login check
val stmt = conn.prepareStatement("""
SELECT
out_no_op,
diff --git a/bank/src/test/kotlin/BankIntegrationApiTest.kt b/bank/src/test/kotlin/BankIntegrationApiTest.kt
index ac1bcefb..69e8ac0e 100644
--- a/bank/src/test/kotlin/BankIntegrationApiTest.kt
+++ b/bank/src/test/kotlin/BankIntegrationApiTest.kt
@@ -142,7 +142,6 @@ class BankIntegrationApiTest {
// POST /taler-integration/withdrawal-operation/UUID/abort
@Test
fun abort() = bankSetup { _ ->
- // TODO auth routine
// Check abort created
client.postA("/accounts/merchant/withdrawals") {
json { "amount" to "KUDOS:1" }
diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt b/bank/src/test/kotlin/CoreBankApiTest.kt
index ad6758a3..1826dbf2 100644
--- a/bank/src/test/kotlin/CoreBankApiTest.kt
+++ b/bank/src/test/kotlin/CoreBankApiTest.kt
@@ -1324,7 +1324,7 @@ class CoreBankTanApiTest {
// Check wrong account
client.postA("/accounts/customer/challenge/$id/confirm") {
json { "tan" to "nice-try" }
- }.assertNotFound(TalerErrorCode.BANK_TRANSACTION_NOT_FOUND)
+ }.assertNotFound(TalerErrorCode.BANK_CHALLENGE_NOT_FOUND)
// Check OK
client.postA("/accounts/merchant/challenge/$id/confirm") {
@@ -1338,7 +1338,7 @@ class CoreBankTanApiTest {
// Unknown challenge
client.postA("/accounts/merchant/challenge/42/confirm") {
json { "tan" to code }
- }.assertNotFound(TalerErrorCode.BANK_TRANSACTION_NOT_FOUND)
+ }.assertNotFound(TalerErrorCode.BANK_CHALLENGE_NOT_FOUND)
}
// Check invalidation
@@ -1353,7 +1353,7 @@ class CoreBankTanApiTest {
fillTanInfo("merchant")
client.postA("/accounts/merchant/challenge/$id/confirm") {
json { "tan" to tanCode(info) }
- }.assertConflict(TalerErrorCode.BANK_TAN_CHALLENGE_FAILED)
+ }.assertConflict(TalerErrorCode.BANK_TAN_CHALLENGE_EXPIRED)
val new = client.postA("/accounts/merchant/challenge/$id")
.assertOkJson<TanTransmission>().tan_info
diff --git a/database-versioning/libeufin-bank-procedures.sql b/database-versioning/libeufin-bank-procedures.sql
index e7f46960..c142e450 100644
--- a/database-versioning/libeufin-bank-procedures.sql
+++ b/database-versioning/libeufin-bank-procedures.sql
@@ -484,7 +484,6 @@ IF NOT FOUND THEN
ELSIF out_same_account OR out_tan_required THEN
RETURN;
END IF;
--- TODO check balance insufficient ?
-- Perform bank transfer
SELECT
transfer.out_balance_insufficient,
diff --git a/util/src/main/kotlin/TalerErrorCode.kt b/util/src/main/kotlin/TalerErrorCode.kt
index 8638dfc2..162a84c2 100644
--- a/util/src/main/kotlin/TalerErrorCode.kt
+++ b/util/src/main/kotlin/TalerErrorCode.kt
@@ -2650,7 +2650,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The backend lacks a wire transfer method configuration option for the given instance. Thus, this instance is unavailable (not findable for creating new orders).
+ * The merchant instance has no active bank accounts configured. However, at least one bank account must be available to create new orders.
* Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2658,7 +2658,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The proposal had no timestamp and the backend failed to obtain the local time. Likely to be an internal error.
+ * The proposal had no timestamp and the merchant backend failed to obtain the current local time.
* Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2666,7 +2666,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The order provided to the backend could not be parsed, some required fields were missing or ill-formed.
+ * The order provided to the backend could not be parsed; likely some required fields were missing or ill-formed.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2674,7 +2674,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The backend encountered an error: the proposal already exists.
+ * A conflicting order (sharing the same order identifier) already exists at this merchant backend instance.
* Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2682,7 +2682,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The request is invalid: the wire deadline is before the refund deadline.
+ * The order creation request is invalid because the given wire deadline is before the refund deadline.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2690,7 +2690,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The request is invalid: a delivery date was given, but it is in the past.
+ * The order creation request is invalid because the delivery date given is in the past.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2698,7 +2698,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The request is invalid: the wire deadline for the order would be "never".
+ * The order creation request is invalid because a wire deadline of "never" is not allowed.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2706,7 +2706,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The request is invalid: a payment deadline was given, but it is in the past.
+ * The order ceration request is invalid because the given payment deadline is in the past.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2714,7 +2714,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The request is invalid: a refund deadline was given, but it is in the past.
+ * The order creation request is invalid because the given refund deadline is in the past.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2722,7 +2722,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The backend does not trust any exchange that would allow funds to be wired to any bank account of this instance using the selected wire method. Note that right now, we do not support the use of exchange bank accounts with mandatory currency conversion.
+ * The backend does not trust any exchange that would allow funds to be wired to any bank account of this instance using the wire method specified with the order. Note that right now, we do not support the use of exchange bank accounts with mandatory currency conversion.
* Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2746,7 +2746,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The order provided to the backend could not be deleted, our offer is still valid and awaiting payment.
+ * The order provided to the backend could not be deleted, our offer is still valid and awaiting payment. Deletion may work later after the offer has expired if it remains unpaid.
* Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2762,7 +2762,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The amount to be refunded is inconsistent: either is lower than the previous amount being awarded, or it is too big to be paid back. In this second case, the fault stays on the business dept. side.
+ * The amount to be refunded is inconsistent: either is lower than the previous amount being awarded, or it exceeds the original price paid by the customer.
* Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2770,7 +2770,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The frontend gave an unpaid order id to issue the refund to.
+ * Only paid orders can be refunded, and the frontend specified an unpaid order to issue a refund for.
* Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -2778,7 +2778,7 @@ enum class TalerErrorCode(val code: Int) {
/**
- * The refund delay was set to 0 and thus no refunds are allowed for this order.
+ * The refund delay was set to 0 and thus no refunds are ever allowed for this order.
* Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403).
* (A value of 0 indicates that the error is generated client-side).
*/
@@ -3498,6 +3498,22 @@ enum class TalerErrorCode(val code: Int) {
/**
+ * The referenced challenge was not found.
+ * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ BANK_CHALLENGE_NOT_FOUND(5143),
+
+
+ /**
+ * The referenced challenge has expired.
+ * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ BANK_TAN_CHALLENGE_EXPIRED(5144),
+
+
+ /**
* The sync service failed find the account in its database.
* Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
* (A value of 0 indicates that the error is generated client-side).