aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-10-13 14:43:50 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-10-13 21:16:50 +0200
commita5f50083e65a3e9a0945b150701349afa81a0e9e (patch)
treea6a89fa83c78d812a7f6a38e851659cf443269dd /src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
parenta8b2456ecf47e2650f8bac1da3cc25b4ace54d24 (diff)
downloadmerchant-a5f50083e65a3e9a0945b150701349afa81a0e9e.tar.gz
merchant-a5f50083e65a3e9a0945b150701349afa81a0e9e.tar.bz2
merchant-a5f50083e65a3e9a0945b150701349afa81a0e9e.zip
work towards multi-currency support
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c')
-rw-r--r--src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c b/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
index 16bd5940..1a21790d 100644
--- a/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
+++ b/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
@@ -537,7 +537,7 @@ compute_total_requested (void *cls,
{
pc->http_status = MHD_HTTP_BAD_REQUEST;
pc->response =
- TALER_MHD_make_error (TALER_EC_GENERIC_CURRENCY_MISMATCH,
+ TALER_MHD_make_error (TALER_EC_MERCHANT_GENERIC_CURRENCY_MISMATCH,
"Must not mix currencies when picking up rewards");
MHD_resume_connection (pc->connection);
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
@@ -920,6 +920,23 @@ RETRY:
TALER_EC_MERCHANT_REWARD_PICKUP_HAS_EXPIRED,
hc->infix);
}
+ if (GNUNET_OK !=
+ TALER_amount_cmp_currency (&total_authorized,
+ &total_picked_up))
+ {
+ /* This could theoretically happen if the exchange changed
+ its currency between us approving the reward
+ and the client then picks it up with the new
+ exchange currency. And of course the backend
+ would have had to get the new /keys of the
+ exchange already as well. Very theoretical case. */
+ GNUNET_break_op (0);
+ TMH_db->rollback (TMH_db->cls);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_MERCHANT_GENERIC_CURRENCY_MISMATCH,
+ "picked up amount does not use same currency as authorized amount");
+ }
if (0 >
TALER_amount_subtract (&total_remaining,
&total_authorized,