commit 37c215dd63fdfd2bb4ff09ddb3804f2f7d3190b4
parent 8d764fab40d847d32f293e6ef65cf1d384557e19
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 7 Dec 2025 15:17:20 +0100
implement #10637
Diffstat:
5 files changed, 73 insertions(+), 11 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c
@@ -237,11 +237,16 @@ cleanup (void *ctx)
struct ProcessRefundsClosure
{
/**
- * Place where we accumulate the refunds.
+ * Place where we accumulate the granted refunds.
*/
struct TALER_Amount total_refund_amount;
/**
+ * Place where we accumulate the pending refunds.
+ */
+ struct TALER_Amount pending_refund_amount;
+
+ /**
* Set to an error code if something goes wrong.
*/
enum TALER_ErrorCode ec;
@@ -288,6 +293,11 @@ process_refunds_cb (void *cls,
TALER_amount_add (&prc->total_refund_amount,
&prc->total_refund_amount,
refund_amount));
+ if (pending)
+ GNUNET_assert (0 <=
+ TALER_amount_add (&prc->pending_refund_amount,
+ &prc->pending_refund_amount,
+ refund_amount));
}
@@ -315,6 +325,9 @@ add_order (void *cls,
bool wired;
struct TALER_MERCHANT_Contract *contract = NULL;
int16_t choice_index = -1;
+ struct ProcessRefundsClosure prc = {
+ .ec = TALER_EC_NONE
+ };
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Adding order `%s' (%llu) to result set at instance `%s'\n",
@@ -402,13 +415,8 @@ add_order (void *cls,
goto cleanup;
}
- if (GNUNET_TIME_absolute_is_future (
- contract->refund_deadline.abs_time) &&
- paid)
+ if (paid)
{
- struct ProcessRefundsClosure prc = {
- .ec = TALER_EC_NONE
- };
const struct TALER_Amount *brutto;
switch (contract->version)
@@ -429,10 +437,13 @@ add_order (void *cls,
GNUNET_break (0);
goto cleanup;
}
-
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (brutto->currency,
&prc.total_refund_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (brutto->currency,
+ &prc.pending_refund_amount));
+
qs = TMH_db->lookup_refunds_detailed (TMH_db->cls,
po->instance_id,
&h_contract_terms,
@@ -481,6 +492,21 @@ add_order (void *cls,
TALER_JSON_pack_amount (
"amount",
&contract->details.v0.brutto),
+ GNUNET_JSON_pack_allow_null (
+ TALER_JSON_pack_amount (
+ "refund_amount",
+ paid
+ ? &prc.total_refund_amount
+ : NULL)),
+ GNUNET_JSON_pack_allow_null (
+ TALER_JSON_pack_amount (
+ "pending_refund_amount",
+ paid
+ ? &prc.pending_refund_amount
+ : NULL)),
+ TALER_JSON_pack_amount (
+ "amount",
+ &contract->details.v0.brutto),
GNUNET_JSON_pack_string ("summary",
contract->summary),
GNUNET_JSON_pack_bool ("refundable",
@@ -509,6 +535,18 @@ add_order (void *cls,
creation_time),
TALER_JSON_pack_amount ("amount",
&choice->amount),
+ GNUNET_JSON_pack_allow_null (
+ TALER_JSON_pack_amount (
+ "refund_amount",
+ paid
+ ? &prc.total_refund_amount
+ : NULL)),
+ GNUNET_JSON_pack_allow_null (
+ TALER_JSON_pack_amount (
+ "pending_refund_amount",
+ paid
+ ? &prc.pending_refund_amount
+ : NULL)),
GNUNET_JSON_pack_string ("summary",
contract->summary),
GNUNET_JSON_pack_bool ("refundable",
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
@@ -2773,6 +2773,19 @@ struct TALER_MERCHANT_OrderEntry
*/
bool paid;
+ /**
+ * Total amount of refunds granted (but not necessarily
+ * accepted by the wallet). Only set if @e paid, otherwise
+ * set to an invalid amount!
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * Total amount of refunds pending (wallet did not pick them up).
+ * Only set if @e paid, otherwise set to an invalid amount!
+ */
+ struct TALER_Amount pending_refund_amount;
+
};
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
@@ -10,7 +10,7 @@ lib_LTLIBRARIES = \
libtalermerchant.la
libtalermerchant_la_LDFLAGS = \
- -version-info 8:0:0 \
+ -version-info 9:0:1 \
-no-undefined
libtalermerchant_la_SOURCES = \
diff --git a/src/lib/merchant_api_get_config.c b/src/lib/merchant_api_get_config.c
@@ -39,7 +39,7 @@
/**
* How many configs are we backwards-compatible with?
*/
-#define MERCHANT_PROTOCOL_AGE 12
+#define MERCHANT_PROTOCOL_AGE 0
/**
* How many exchanges do we allow at most per merchant?
diff --git a/src/lib/merchant_api_get_orders.c b/src/lib/merchant_api_get_orders.c
@@ -16,7 +16,7 @@
*/
/**
* @file merchant_api_get_orders.c
- * @brief Implementation of the GET /orders request of the merchant's HTTP API
+ * @brief Implementation of the GET /private/orders request of the merchant's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@@ -94,6 +94,9 @@ parse_orders (const json_t *ia,
size_t index;
json_t *value;
+ memset (oes,
+ 0,
+ sizeof (oes));
json_array_foreach (ia, index, value) {
struct TALER_MERCHANT_OrderEntry *ie = &oes[index];
struct GNUNET_JSON_Specification spec[] = {
@@ -105,6 +108,14 @@ parse_orders (const json_t *ia,
&ie->order_serial),
TALER_JSON_spec_amount_any ("amount",
&ie->amount),
+ GNUNET_JSON_spec_mark_optional (
+ TALER_JSON_spec_amount_any ("refund_amount",
+ &ie->refund_amount),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ TALER_JSON_spec_amount_any ("pending_refund_amount",
+ &ie->pending_refund_amount),
+ NULL),
GNUNET_JSON_spec_string ("summary",
&ie->summary),
GNUNET_JSON_spec_bool ("refundable",