From 6d41df4ffbc0d921aecb265ecb49b15df5c7178e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 22 Mar 2024 14:05:42 +0100 Subject: add logic to preserve and possibly update minimum_age in contract terms --- src/backend/taler-merchant-httpd_private-post-orders.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/backend') diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index be8b8d1d..6be11f16 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -330,6 +330,11 @@ struct OrderContext */ const json_t *extra; + /** + * Minimum age required by the order. + */ + uint32_t minimum_age; + } parse_order; /** @@ -1322,6 +1327,9 @@ serialize_order (struct OrderContext *oc) GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("fulfillment_url", oc->parse_order.fulfillment_url)), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_uint64 ("minimum_age", + oc->parse_order.minimum_age)), GNUNET_JSON_pack_array_incref ("products", oc->merge_inventory.products), GNUNET_JSON_pack_data_auto ("h_wire", @@ -1575,6 +1583,10 @@ parse_order (struct OrderContext *oc) GNUNET_JSON_spec_timestamp ("delivery_date", &oc->parse_order.delivery_date), NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_uint32 ("minimum_age", + &oc->parse_order.minimum_age), + NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_relative_time ("auto_refund", &oc->parse_order.auto_refund), @@ -1996,6 +2008,9 @@ merge_inventory (struct OrderContext *oc) ip->product_id); return; } + oc->parse_order.minimum_age + = GNUNET_MAX (oc->parse_order.minimum_age, + pd.minimum_age); { json_t *p; -- cgit v1.2.3