summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-04-11 14:17:11 +0200
committerChristian Grothoff <christian@grothoff.org>2021-04-11 14:17:11 +0200
commit9b5717ecbc40a02e71572c490c7e2882f8109b32 (patch)
tree31ed2a130416e6b7f199b0606334b4b106dc65fd
parenta9efaf54b146a1b816b83229363173ed518e6ce1 (diff)
downloadmerchant-9b5717ecbc40a02e71572c490c7e2882f8109b32.tar.gz
merchant-9b5717ecbc40a02e71572c490c7e2882f8109b32.tar.bz2
merchant-9b5717ecbc40a02e71572c490c7e2882f8109b32.zip
allow refund_delay to override default wire deadline; check if confliciting refund_deadline exists already during order creation
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index a06b6ac6..528cb9ef 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -808,20 +808,20 @@ patch_order (struct MHD_Connection *connection,
if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us ==
refund_deadline.abs_value_us)
{
- struct GNUNET_TIME_Absolute rd =
- GNUNET_TIME_relative_to_absolute (refund_delay);
+ refund_deadline = GNUNET_TIME_relative_to_absolute (refund_delay);
- (void) GNUNET_TIME_round_abs (&rd);
+ (void) GNUNET_TIME_round_abs (&refund_deadline);
if (0 == refund_delay.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Refund delay is zero, no refunds are possible for this order\n");
- rd = now; /* if delay was 0, ensure that refund_deadline == timestamp */
+ refund_deadline = now; /* if delay was 0, ensure that refund_deadline == timestamp */
}
GNUNET_assert (0 ==
json_object_set_new (order,
"refund_deadline",
- GNUNET_JSON_from_time_abs (rd)));
+ GNUNET_JSON_from_time_abs (
+ refund_deadline)));
}
}
@@ -842,13 +842,26 @@ patch_order (struct MHD_Connection *connection,
struct GNUNET_TIME_Absolute t;
t = GNUNET_TIME_relative_to_absolute (
- settings->default_wire_transfer_delay);
+ GNUNET_TIME_relative_max (settings->default_wire_transfer_delay,
+ refund_delay));
+ wire_deadline = GNUNET_TIME_absolute_max (refund_deadline,
+ wire_deadline);
(void) GNUNET_TIME_round_abs (&t);
GNUNET_assert (0 ==
json_object_set_new (order,
"wire_transfer_deadline",
GNUNET_JSON_from_time_abs (t)));
}
+ if (wire_deadline.abs_value_us < refund_deadline.abs_value_us)
+ {
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_REFUND_AFTER_WIRE_DEADLINE,
+ NULL);
+
+ }
if (GNUNET_OK !=
TALER_amount_is_valid (&max_wire_fee))