merchant

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

commit 5d2a00bda6d5ef3a9a0443fb4376d4919470076a
parent 8fa1a8ea98229d27f5ca39cb3ee2744fdc047c6d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 28 Nov 2025 19:43:54 +0100

fix v1 contract repurchase crash

Diffstat:
Msrc/backend/taler-merchant-httpd_private-get-orders-ID.c | 51+++++++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -746,7 +746,8 @@ phase_parse_contract (struct GetOrderRequestContext *gorc) GNUNET_break (0); phase_end (gorc, TALER_MHD_reply_with_error ( - gorc->sc.con, MHD_HTTP_INTERNAL_SERVER_ERROR, + gorc->sc.con, + MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_INVARIANT_FAILURE, NULL)); return; @@ -757,8 +758,9 @@ phase_parse_contract (struct GetOrderRequestContext *gorc) } else { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "choice index %i for order %s is invalid or not yet available", + GNUNET_break (gorc->order_only); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Choice index %i for order %s is invalid or not yet available", gorc->choice_index, gorc->contract_terms->order_id); } @@ -776,19 +778,18 @@ phase_parse_contract (struct GetOrderRequestContext *gorc) } } - if (! gorc->order_only && GNUNET_OK != - TALER_JSON_contract_hash (gorc->contract_terms_json, - &gorc->h_contract_terms)) + if ( (! gorc->order_only) && + (GNUNET_OK != + TALER_JSON_contract_hash (gorc->contract_terms_json, + &gorc->h_contract_terms)) ) { - { - GNUNET_break (0); - phase_end (gorc, - TALER_MHD_reply_with_error (gorc->sc.con, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, - NULL)); - return; - } + GNUNET_break (0); + phase_end (gorc, + TALER_MHD_reply_with_error (gorc->sc.con, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, + NULL)); + return; } GNUNET_assert (NULL != gorc->contract_terms_json); GNUNET_assert (NULL != gorc->contract_terms); @@ -867,14 +868,14 @@ phase_check_repurchase (struct GetOrderRequestContext *gorc) "Running re-purchase detection for %s/%s\n", gorc->session_id, gorc->contract_terms->fulfillment_url); - qs = TMH_db->lookup_order_by_fulfillment (TMH_db->cls, - hc->instance->settings.id, - gorc->contract_terms-> - fulfillment_url, - gorc->session_id, - TALER_EXCHANGE_YNA_NO != - gorc->allow_refunded_for_repurchase, - &already_paid_order_id); + qs = TMH_db->lookup_order_by_fulfillment ( + TMH_db->cls, + hc->instance->settings.id, + gorc->contract_terms->fulfillment_url, + gorc->session_id, + TALER_EXCHANGE_YNA_NO != + gorc->allow_refunded_for_repurchase, + &already_paid_order_id); if (0 > qs) { /* single, read-only SQL statements should never cause @@ -942,7 +943,9 @@ phase_check_repurchase (struct GetOrderRequestContext *gorc) /* undefined for unpaid v1 contracts */ GNUNET_JSON_pack_allow_null ( TALER_JSON_pack_amount ("total_amount", - &gorc->contract_amount)), + TALER_amount_is_valid (&gorc->contract_amount) + ? &gorc->contract_amount + : NULL)), GNUNET_JSON_pack_string ("summary", gorc->contract_terms->summary), GNUNET_JSON_pack_timestamp ("pay_deadline",