merchant

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

commit 01a34b17bf37e4c4bbe59e47cbc480f31e85ffb0
parent 6a4aeb9cd66c6586042cfe15438b7ad25b94804d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 29 Dec 2024 16:54:35 +0100

fix #9425

Diffstat:
Msrc/backend/taler-merchant-httpd_config.c | 2+-
Msrc/backend/taler-merchant-httpd_mhd.c | 9+++++++--
Msrc/backend/taler-merchant-httpd_post-orders-ID-abort.c | 7+------
Msrc/backend/taler-merchant-httpd_post-orders-ID-refund.c | 35+++++++++++++++++++----------------
Msrc/include/taler_merchant_service.h | 1+
Msrc/lib/merchant_api_post_order_abort.c | 4+++-
6 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c @@ -43,7 +43,7 @@ * #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in * merchant_api_config.c! */ -#define MERCHANT_PROTOCOL_VERSION "17:0:13" +#define MERCHANT_PROTOCOL_VERSION "18:0:14" /** diff --git a/src/backend/taler-merchant-httpd_mhd.c b/src/backend/taler-merchant-httpd_mhd.c @@ -57,14 +57,19 @@ bool TMH_MHD_test_html_desired (struct MHD_Connection *connection) { const char *accept; + double json_q; + double html_q; accept = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT); if (NULL == accept) return false; /* nothing selected, we read this as not HTML */ - if (0.0 < TALER_pattern_matches (accept, - "text/html")) + html_q = TALER_pattern_matches (accept, + "text/html"); + json_q = TALER_pattern_matches (accept, + "application/json"); + if (html_q > json_q) return true; return false; } diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -633,7 +633,6 @@ refund_coins (void *cls, struct AbortContext *ac = cls; struct GNUNET_TIME_Timestamp now; - (void) amount_with_fee; (void) deposit_fee; (void) refund_fee; now = GNUNET_TIME_timestamp_get (); @@ -649,7 +648,7 @@ refund_coins (void *cls, strcmp (exchange_url, rdi->exchange_url)) ) continue; /* not in request */ - + rdi->amount_with_fee = *amount_with_fee; /* Store refund in DB */ qs = TMH_db->refund_coin (TMH_db->cls, ac->hc->instance->settings.id, @@ -884,10 +883,6 @@ parse_abort (struct MHD_Connection *connection, struct RefundDetails *rd = &ac->rd[coins_index]; const char *exchange_url; struct GNUNET_JSON_Specification ispec[] = { - /* FIXME-#9425: this is breaking multi-currency support! */ - TALER_JSON_spec_amount ("contribution", - TMH_currency, - &rd->amount_with_fee), TALER_JSON_spec_web_url ("exchange_url", &exchange_url), GNUNET_JSON_spec_fixed_auto ("coin_pub", diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -666,23 +666,26 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, NULL); } + qs = TMH_db->lookup_refunds_detailed (TMH_db->cls, + hc->instance->settings.id, + &prd->h_contract_terms, + &process_refunds_cb, + prd); + if (0 > qs) { - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TMH_currency, - &prd->refund_amount)); - qs = TMH_db->lookup_refunds_detailed (TMH_db->cls, - hc->instance->settings.id, - &prd->h_contract_terms, - &process_refunds_cb, - prd); - if (0 > qs) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "detailed refunds"); - } + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "detailed refunds"); + } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "no coins found that could be refunded"); } /* Now launch exchange interactions, unless we already have the diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h @@ -3759,6 +3759,7 @@ struct TALER_MERCHANT_AbortCoin /** * Amount this coin contributes to (including fee). + * FIXME: no longer needed since **v18**. Remove eventually! */ struct TALER_Amount amount_with_fee; diff --git a/src/lib/merchant_api_post_order_abort.c b/src/lib/merchant_api_post_order_abort.c @@ -341,6 +341,7 @@ TALER_MERCHANT_order_abort ( j_coin = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("coin_pub", &ac->coin_pub), + /* FIXME: no longer needed since **v18**, remove eventually! */ TALER_JSON_pack_amount ("contribution", &ac->amount_with_fee), GNUNET_JSON_pack_string ("exchange_url", @@ -417,7 +418,8 @@ TALER_MERCHANT_order_abort ( void -TALER_MERCHANT_order_abort_cancel (struct TALER_MERCHANT_OrderAbortHandle *oah) +TALER_MERCHANT_order_abort_cancel ( + struct TALER_MERCHANT_OrderAbortHandle *oah) { if (NULL != oah->job) {