commit e5eaf68d63f5bf257f839c0c505cd3e1ea63e82e
parent 26625a9fb94814818a5e0b937a3e307726dcb47d
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 9 Oct 2025 12:29:28 +0200
return pay_deadline with order creation
Diffstat:
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1268,6 +1268,8 @@ phase_execute_order (struct OrderContext *oc)
MHD_HTTP_OK,
GNUNET_JSON_pack_string ("order_id",
oc->parse_order.order_id),
+ GNUNET_JSON_pack_timestamp ("pay_deadline",
+ oc->parse_order.pay_deadline),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_data_varsize (
"token",
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
@@ -2279,6 +2279,13 @@ struct TALER_MERCHANT_PostOrdersReply
*/
const struct TALER_ClaimTokenP *token;
+ /**
+ * When will the order have to be paid?
+ * Note: only available since protocol v21,
+ * will be zero if server is older.
+ */
+ struct GNUNET_TIME_Timestamp pay_deadline;
+
} ok;
/**
diff --git a/src/lib/merchant_api_common.c b/src/lib/merchant_api_common.c
@@ -373,6 +373,7 @@ TALER_MERCHANT_handle_order_creation_response_ (
case MHD_HTTP_OK:
{
bool no_token;
+ bool no_pay_deadline;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("order_id",
&por.details.ok.order_id),
@@ -380,6 +381,11 @@ TALER_MERCHANT_handle_order_creation_response_ (
GNUNET_JSON_spec_fixed_auto ("token",
&token),
&no_token),
+ GNUNET_JSON_spec_mark_optional (
+ /* optional for pre-v21 compatibility */
+ GNUNET_JSON_spec_timestamp ("pay_deadline",
+ &por.details.ok.pay_deadline),
+ &no_pay_deadline),
GNUNET_JSON_spec_end ()
};
@@ -396,6 +402,12 @@ TALER_MERCHANT_handle_order_creation_response_ (
{
if (! no_token)
por.details.ok.token = &token;
+ if (no_pay_deadline)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Talking to outdated merchant backend, payment deadline unavailable.\n");
+ por.details.ok.pay_deadline = GNUNET_TIME_UNIT_ZERO_TS;
+ }
}
}
break;