merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 3e525220dd33b19203ffce1d44728a620e49da68
parent 7308c73fc1680e46c2fdbb6011a24f0b381ff55a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 25 May 2026 23:33:49 +0200

fix misc. minor bugs from refactoring

Diffstat:
Msrc/backend/taler-merchant-httpd_get-orders-ORDER_ID.c | 11+++++++++++
Msrc/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c | 4++--
Msrc/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c | 3---
Msrc/util/base_terms_parse.c | 13+++++--------
Msrc/util/base_terms_serialize.c | 16++++++++--------
Msrc/util/contract_choice_parse.c | 14+++++---------
Msrc/util/contract_parse.c | 2++
Msrc/util/contract_serialize.c | 4++--
Msrc/util/order_choice_serialize.c | 8+++++++-
Msrc/util/product_parse.c | 7++++++-
Msrc/util/product_sold_serialize.c | 2++
Msrc/util/token_family_parse.c | 3+++
12 files changed, 53 insertions(+), 34 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-orders-ORDER_ID.c b/src/backend/taler-merchant-httpd_get-orders-ORDER_ID.c @@ -394,6 +394,17 @@ god_cleanup (void *cls) json_decref (god->order_json); god->order_json = NULL; } + if (NULL != god->contract_terms) + { + TALER_MERCHANT_contract_free (god->contract_terms); + god->contract_terms = NULL; + god->pc = NULL; + } + if (NULL != god->pc) + { + TALER_MERCHANT_proto_contract_free (god->pc); + god->pc = NULL; + } if (NULL != god->order) { TALER_MERCHANT_order_free (god->order); diff --git a/src/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c b/src/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c @@ -839,7 +839,6 @@ phase_parse_contract (struct GetOrderRequestContext *gorc) { gorc->contract_terms = TALER_MERCHANT_contract_parse ( gorc->contract_terms_json); - gorc->pc = gorc->contract_terms->pc; if (NULL == gorc->contract_terms) { GNUNET_break (0); @@ -851,7 +850,8 @@ phase_parse_contract (struct GetOrderRequestContext *gorc) hc->infix)); return; } - gorc->ct = gorc->contract_terms->pc->base; + gorc->pc = gorc->contract_terms->pc; + gorc->ct = gorc->pc->base; gorc->timestamp = gorc->contract_terms->pc->timestamp; } } diff --git a/src/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c b/src/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c @@ -499,9 +499,6 @@ parse_using_templates_paivana_request ( if (GNUNET_OK != res) { GNUNET_break_op (0); - json_dumpf (uc->hc->request_body, - stderr, - JSON_INDENT (2)); use_finalize_parse (uc, res); return GNUNET_SYSERR; diff --git a/src/util/base_terms_parse.c b/src/util/base_terms_parse.c @@ -113,14 +113,6 @@ TALER_MERCHANT_base_terms_parse ( ename); goto cleanup; } - - if (GNUNET_OK != res) - { - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse contract\n"); - goto cleanup; - } return ct; cleanup: @@ -154,5 +146,10 @@ TALER_MERCHANT_base_terms_free ( json_decref (ct->extra); ct->extra = NULL; } + if (NULL != ct->summary_i18n) + { + json_decref (ct->summary_i18n); + ct->summary_i18n = NULL; + } GNUNET_free (ct); } diff --git a/src/util/base_terms_serialize.c b/src/util/base_terms_serialize.c @@ -44,8 +44,8 @@ TALER_MERCHANT_base_terms_serialize ( GNUNET_JSON_pack_string ("summary", ct->summary), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_steal ("summary_i18n", - ct->summary_i18n)), + GNUNET_JSON_pack_object_incref ("summary_i18n", + ct->summary_i18n)), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("public_reorder_url", ct->public_reorder_url)), @@ -56,11 +56,11 @@ TALER_MERCHANT_base_terms_serialize ( GNUNET_JSON_pack_string ("fulfillment_message", ct->fulfillment_message)), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_steal ("fulfillment_message_i18n", - ct->fulfillment_message_i18n)), + GNUNET_JSON_pack_object_incref ("fulfillment_message_i18n", + ct->fulfillment_message_i18n)), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_steal ("delivery_location", - ct->delivery_location)), + GNUNET_JSON_pack_object_incref ("delivery_location", + ct->delivery_location)), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_timestamp ("delivery_date", ct->delivery_date)), @@ -68,8 +68,8 @@ TALER_MERCHANT_base_terms_serialize ( GNUNET_JSON_pack_time_rel ("auto_refund", ct->auto_refund)), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_steal ("extra", - ct->extra)), + GNUNET_JSON_pack_object_incref ("extra", + ct->extra)), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_uint64 ("minimum_age", ct->minimum_age)), diff --git a/src/util/contract_choice_parse.c b/src/util/contract_choice_parse.c @@ -176,11 +176,9 @@ TALER_MERCHANT_parse_contract_choice_output ( { const json_t *donau_urls = NULL; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_amount_any ( - "amount", - &output->details.donation_receipt.amount), - NULL), + TALER_JSON_spec_amount_any ( + "amount", + &output->details.donation_receipt.amount), GNUNET_JSON_spec_array_const ("donau_urls", &donau_urls), GNUNET_JSON_spec_end () @@ -288,10 +286,8 @@ parse_contract_choices ( GNUNET_JSON_spec_object_copy ("description_i18n", &choice->description_i18n), NULL), - GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_amount_any ("max_fee", - &choice->max_fee), - NULL), + TALER_JSON_spec_amount_any ("max_fee", + &choice->max_fee), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_array_const ("inputs", &jinputs), diff --git a/src/util/contract_parse.c b/src/util/contract_parse.c @@ -293,6 +293,8 @@ TALER_MERCHANT_proto_contract_free ( pc->base = NULL; } GNUNET_free (pc->wire_method); + GNUNET_free (pc->merchant_base_url); + TALER_MERCHANT_metadata_free (&pc->merchant); if (NULL != pc->exchanges) { json_decref (pc->exchanges); diff --git a/src/util/contract_serialize.c b/src/util/contract_serialize.c @@ -159,8 +159,8 @@ success: &pc->h_wire), GNUNET_JSON_pack_string ("wire_method", pc->wire_method), - GNUNET_JSON_pack_array_steal ("exchanges", - pc->exchanges), + GNUNET_JSON_pack_array_incref ("exchanges", + pc->exchanges), GNUNET_JSON_pack_object_steal (NULL, details)); } diff --git a/src/util/order_choice_serialize.c b/src/util/order_choice_serialize.c @@ -86,7 +86,13 @@ json_from_order_output ( GNUNET_JSON_pack_string ("token_family_slug", output->details.token.token_family_slug), GNUNET_JSON_pack_uint64 ("count", - output->details.token.count)); + output->details.token.count), + GNUNET_TIME_absolute_is_zero (output->details.token.valid_at.abs_time) + ? GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("dummy", + NULL)) + : GNUNET_JSON_pack_timestamp ("valid_at", + output->details.token.valid_at)); case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT: return GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("type", diff --git a/src/util/product_parse.c b/src/util/product_parse.c @@ -148,6 +148,10 @@ TALER_MERCHANT_parse_product_sold (const json_t *pj, &legacy_quantity), &no_quantity), GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_bool ("prices_are_net", + &r->prices_are_net), + NULL), + GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("unit_quantity", &unit_quantity_s), &no_unit_quantity), @@ -237,7 +241,8 @@ TALER_MERCHANT_parse_product_sold (const json_t *pj, json_t *price_i; GNUNET_assert (len < UINT_MAX); - r->prices = GNUNET_new_array ((unsigned int) len, + r->prices_length = (unsigned int) len; + r->prices = GNUNET_new_array (r->prices_length, struct TALER_Amount); json_array_foreach (prices, i, price_i) { diff --git a/src/util/product_sold_serialize.c b/src/util/product_sold_serialize.c @@ -88,6 +88,8 @@ TALER_MERCHANT_product_sold_serialize ( p->unit_quantity.integer) : GNUNET_JSON_pack_string ("dummy", NULL) ), + GNUNET_JSON_pack_bool ("prices_are_net", + p->prices_are_net), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("unit", p->unit)), diff --git a/src/util/token_family_parse.c b/src/util/token_family_parse.c @@ -54,6 +54,9 @@ TALER_MERCHANT_contract_token_family_free ( for (unsigned int i = 0; i < family->details.subscription. trusted_domains_len; i++) GNUNET_free (family->details.subscription.trusted_domains[i]); + GNUNET_array_grow (family->details.subscription.trusted_domains, + family->details.subscription.trusted_domains_len, + 0); break; } }