From 26f72f8572cf0d04cd0da718d34dad4ba479289c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 12 Aug 2020 13:02:47 +0200 Subject: fix refund handling: allow refund increases for the same coin --- src/lib/exchange_api_refund.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/lib/exchange_api_refund.c') diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 537be7b84..37c60e07e 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -153,7 +153,6 @@ handle_refund_finished (void *cls, .http_status = (unsigned int) response_code }; - rh->job = NULL; switch (response_code) { @@ -179,7 +178,9 @@ handle_refund_finished (void *cls, break; case MHD_HTTP_BAD_REQUEST: /* This should never happen, either us or the exchange is buggy - (or API version conflict); just pass JSON reply to the application */ + (or API version conflict); also can happen if the currency + differs (which we should obviously never support). + Just pass JSON reply to the application */ hr.ec = TALER_JSON_get_error_code (j); hr.hint = TALER_JSON_get_error_hint (j); break; @@ -196,6 +197,13 @@ handle_refund_finished (void *cls, hr.ec = TALER_JSON_get_error_code (j); hr.hint = TALER_JSON_get_error_hint (j); break; + case MHD_HTTP_CONFLICT: + /* Requested total refunds exceed deposited amount */ + hr.ec = TALER_JSON_get_error_code (j); + hr.hint = TALER_JSON_get_error_hint (j); + // FIXME: check that 'history' contains a coin history that + // demonstrates that another refund would exceed the deposit amount! + break; case MHD_HTTP_GONE: /* Kind of normal: the money was already sent to the merchant (it was too late for the refund). */ @@ -203,16 +211,12 @@ handle_refund_finished (void *cls, hr.hint = TALER_JSON_get_error_hint (j); break; case MHD_HTTP_PRECONDITION_FAILED: - /* Client request was inconsistent; might be a currency mismatch - problem. */ - hr.ec = TALER_JSON_get_error_code (j); - hr.hint = TALER_JSON_get_error_hint (j); - break; - case MHD_HTTP_CONFLICT: - /* Two refund requests were made about the same deposit, but - carrying different refund transaction ids. */ + /* Two different refund requests were made about the same deposit, but + carrying identical refund transaction ids. */ hr.ec = TALER_JSON_get_error_code (j); hr.hint = TALER_JSON_get_error_hint (j); + // FIXME: check that 'history' contains a duly signed refund request + // for the same rtransaction ID but a different amount! break; case MHD_HTTP_INTERNAL_SERVER_ERROR: /* Server had an internal issue; we should retry, but this API -- cgit v1.2.3