commit 9105ef268853675c1a227847ec3dd2bbc25c1753
parent dc5b33905bd3344dba9f250e7c2589f0179a50e7
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 24 Mar 2026 00:54:20 +0100
fix some discrepancies in libtalermerchant with respect to actual latest REST API implemented by the server
Diffstat:
5 files changed, 54 insertions(+), 45 deletions(-)
diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-refund.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-refund.h
@@ -135,6 +135,11 @@ struct TALER_MERCHANT_PostOrdersRefundResponse
const struct TALER_MERCHANT_PostOrdersRefundDetail *refunds;
/**
+ * Total effective refund amount.
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
* Merchant public key.
*/
struct TALER_MerchantPublicKeyP merchant_pub;
diff --git a/src/lib/merchant_api_get-private-webhooks-WEBHOOK_ID.c b/src/lib/merchant_api_get-private-webhooks-WEBHOOK_ID.c
@@ -108,10 +108,14 @@ handle_get_webhook_finished (void *cls,
&wgr.details.ok.url),
GNUNET_JSON_spec_string ("http_method",
&wgr.details.ok.http_method),
- GNUNET_JSON_spec_string ("header_template",
- &wgr.details.ok.header_template),
- GNUNET_JSON_spec_string ("body_template",
- &wgr.details.ok.body_template),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("header_template",
+ &wgr.details.ok.header_template),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("body_template",
+ &wgr.details.ok.body_template),
+ NULL),
GNUNET_JSON_spec_end ()
};
diff --git a/src/lib/merchant_api_post-orders-ORDER_ID-claim.c b/src/lib/merchant_api_post-orders-ORDER_ID-claim.c
@@ -17,7 +17,7 @@
If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file merchant_api_post-orders-ORDER_ID-claim-new.c
+ * @file merchant_api_post-orders-ORDER_ID-claim.c
* @brief Implementation of the POST /orders/$ID/claim request
* @author Christian Grothoff
*/
@@ -125,54 +125,48 @@ handle_post_order_claim_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"POST /orders/$ID/claim completed with response code %u\n",
(unsigned int) response_code);
-
- if (MHD_HTTP_OK != response_code)
+ switch (response_code)
{
+ case MHD_HTTP_OK:
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Claiming order failed: could not parse JSON response\n");
+ GNUNET_break_op (0);
+ ocr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ ocr.hr.http_status = 0;
+ break;
+ }
+
+ if (GNUNET_OK !=
+ TALER_JSON_contract_hash (ocr.details.ok.contract_terms,
+ &ocr.details.ok.h_contract_terms))
+ {
+ GNUNET_break (0);
+ ocr.hr.ec
+ = TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE;
+ ocr.hr.http_status = 0;
+ break;
+ }
+ break;
+ case MHD_HTTP_CONFLICT:
+ ocr.hr.ec = TALER_JSON_get_error_code (json);
+ ocr.hr.hint = TALER_JSON_get_error_hint (json);
+ break;
+ default:
ocr.hr.ec = TALER_JSON_get_error_code (json);
ocr.hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Claim order failed with HTTP status code %u/%d\n",
(unsigned int) response_code,
(int) ocr.hr.ec);
- poch->cb (poch->cb_cls,
- &ocr);
- TALER_MERCHANT_post_orders_claim_cancel (poch);
- return;
- }
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (json,
- spec,
- NULL, NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Claiming order failed: could not parse JSON response\n");
- GNUNET_break_op (0);
- ocr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
- ocr.hr.http_status = 0;
- poch->cb (poch->cb_cls,
- &ocr);
- TALER_MERCHANT_post_orders_claim_cancel (poch);
- return;
+ break;
}
-
- if (GNUNET_OK !=
- TALER_JSON_contract_hash (ocr.details.ok.contract_terms,
- &ocr.details.ok.h_contract_terms))
- {
- GNUNET_break (0);
- ocr.hr.ec = TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE;
- ocr.hr.http_status = 0;
- GNUNET_JSON_parse_free (spec);
- poch->cb (poch->cb_cls,
- &ocr);
- TALER_MERCHANT_post_orders_claim_cancel (poch);
- return;
- }
-
poch->cb (poch->cb_cls,
&ocr);
- GNUNET_JSON_parse_free (spec);
TALER_MERCHANT_post_orders_claim_cancel (poch);
}
@@ -291,4 +285,4 @@ TALER_MERCHANT_post_orders_claim_cancel (
}
-/* end of merchant_api_post-orders-ORDER_ID-claim-new.c */
+/* end of merchant_api_post-orders-ORDER_ID-claim.c */
diff --git a/src/lib/merchant_api_post-orders-ORDER_ID-refund.c b/src/lib/merchant_api_post-orders-ORDER_ID-refund.c
@@ -130,6 +130,9 @@ handle_refund_finished (void *cls,
GNUNET_JSON_spec_array_const (
"refunds",
&refunds),
+ TALER_JSON_spec_amount_any (
+ "refund_amount",
+ &orr.details.ok.refund_amount),
GNUNET_JSON_spec_fixed_auto (
"merchant_pub",
&orr.details.ok.merchant_pub),
@@ -261,7 +264,6 @@ handle_refund_finished (void *cls,
break;
case MHD_HTTP_NO_CONTENT:
break;
- case MHD_HTTP_CONFLICT:
case MHD_HTTP_NOT_FOUND:
orr.hr.ec = TALER_JSON_get_error_code (json);
orr.hr.hint = TALER_JSON_get_error_hint (json);
diff --git a/src/lib/merchant_api_post-private-orders-ORDER_ID-refund.c b/src/lib/merchant_api_post-private-orders-ORDER_ID-refund.c
@@ -159,6 +159,10 @@ handle_refund_finished (void *cls,
rr.hr.ec = TALER_JSON_get_error_code (json);
rr.hr.hint = TALER_JSON_get_error_hint (json);
break;
+ case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
+ rr.hr.ec = TALER_JSON_get_error_code (json);
+ rr.hr.hint = TALER_JSON_get_error_hint (json);
+ break;
default:
GNUNET_break_op (0);
TALER_MERCHANT_parse_error_details_ (json,