aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-09-10 21:22:28 +0200
committerChristian Grothoff <christian@grothoff.org>2024-09-10 21:22:28 +0200
commit84443a131563749d16c9e07132d67b92a44ab52f (patch)
tree6a5fc9c50918b2d5661556074ac5dde8eea346d5
parentce2c47390bfe0b9f0246b6b242539fc2ded2170b (diff)
handle zero-amount orders better
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c13
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c11
-rw-r--r--src/lib/test_merchant_api_common.c4
3 files changed, 24 insertions, 4 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 349b4d24..555e2959 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -1240,7 +1240,6 @@ process_pay_with_keys (
return;
}
- /* FIXME: actually enforce max_amount below! */
max_amount = eg->total;
if (GNUNET_OK !=
TMH_exchange_check_debit (
@@ -1261,6 +1260,18 @@ process_pay_with_keys (
force_keys (eg);
return;
}
+ if (-1 ==
+ TALER_amount_cmp (&max_amount,
+ &eg->total))
+ {
+ /* max_amount < eg->total */
+ GNUNET_break_op (0);
+ resume_pay_with_error (
+ pc,
+ TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_TRANSACTION_LIMIT_VIOLATION,
+ eg->exchange_url);
+ return;
+ }
if (GNUNET_OK !=
TMH_EXCHANGES_lookup_wire_fee (exchange,
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index 9215bc6f..075c2bbe 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1929,7 +1929,8 @@ get_acceptable (void *cls,
"Exchange %s evaluated at %d\n",
url,
res);
- if (TALER_amount_is_zero (&max_amount))
+ if ( (! TALER_amount_is_zero (&max_amount)) &&
+ (TALER_amount_is_zero (&max_amount)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exchange %s deposit limit is zero, skipping it\n",
@@ -2071,6 +2072,14 @@ get_exchange_keys (void *cls,
static bool
set_exchanges (struct OrderContext *oc)
{
+ if (TALER_amount_is_zero (&oc->parse_order.brutto))
+ {
+ /* Total amount is zero, so we don't actually need exchanges! */
+ oc->set_exchanges.exchanges = json_array ();
+ GNUNET_assert (NULL != oc->set_exchanges.exchanges);
+ oc->phase++;
+ return false;
+ }
/* Note: re-building 'oc->set_exchanges.exchanges' every time here might be a
tad expensive; could likely consider caching the result if it starts to
matter. */
diff --git a/src/lib/test_merchant_api_common.c b/src/lib/test_merchant_api_common.c
index 821e04a8..e0eb49fa 100644
--- a/src/lib/test_merchant_api_common.c
+++ b/src/lib/test_merchant_api_common.c
@@ -27,11 +27,11 @@ int
main (int argc,
const char *const argv[])
{
- (void) argc;
- (void) argv;
struct TALER_MERCHANT_PayUriData pd;
struct TALER_MERCHANT_RefundUriData rd;
+ (void) argc;
+ (void) argv;
GNUNET_log_setup ("test_merchant_api_common",
"WARNING",
NULL);