merchant

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

commit b4b6422ade77e81769b1a6194cbee41441421526
parent d6a26dc86feee4238c7343484cdd29be515c7955
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon,  6 Jul 2026 00:19:14 +0200

fix unnecessary attempt to diagnose 404 into a 409

Diffstat:
Msrc/backend/taler-merchant-httpd_patch-private-templates-TEMPLATE_ID.c | 95+++++++++++++++++--------------------------------------------------------------
Msrc/backend/taler-merchant-httpd_patch-private-webhooks-WEBHOOK_ID.c | 93+++++++++++++------------------------------------------------------------------
2 files changed, 35 insertions(+), 153 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_patch-private-templates-TEMPLATE_ID.c b/src/backend/taler-merchant-httpd_patch-private-templates-TEMPLATE_ID.c @@ -26,69 +26,10 @@ #include "taler-merchant-httpd_patch-private-templates-TEMPLATE_ID.h" #include "taler-merchant-httpd_helper.h" #include <taler/taler_json_lib.h> -#include "merchant-database/lookup_template.h" #include "merchant-database/update_template.h" /** - * Determine the cause of the PATCH failure in more detail and report. - * - * @param connection connection to report on - * @param instance_id instance we are processing - * @param template_id ID of the product to patch - * @param tp template details we failed to set - */ -static enum MHD_Result -determine_cause (struct MHD_Connection *connection, - const char *instance_id, - const char *template_id, - const struct TALER_MERCHANTDB_TemplateDetails *tp) -{ - struct TALER_MERCHANTDB_TemplateDetails tpx; - enum GNUNET_DB_QueryStatus qs; - - qs = TALER_MERCHANTDB_lookup_template (TMH_db, - instance_id, - template_id, - &tpx); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - NULL); - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, - template_id); - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; /* do below */ - } - - { - enum TALER_ErrorCode ec; - - ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; - TALER_MERCHANTDB_template_details_free (&tpx); - GNUNET_break (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE != ec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - ec, - NULL); - } -} - - -/** * PATCH configuration of an existing instance, given its configuration. * * @param rh context of the handler @@ -163,10 +104,11 @@ TMH_private_patch_templates_ID (const struct TMH_RequestHandler *rh, "editable_defaults::%s conflicts with template_contract", key); GNUNET_JSON_parse_free (spec); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - msg); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + msg); GNUNET_free (msg); return ret; } @@ -184,23 +126,26 @@ TMH_private_patch_templates_ID (const struct TMH_RequestHandler *rh, { case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - NULL); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + NULL); break; case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); break; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - ret = determine_cause (connection, - mi->settings.id, - template_id, - &tp); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, + template_id); break; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: ret = TALER_MHD_reply_static (connection, diff --git a/src/backend/taler-merchant-httpd_patch-private-webhooks-WEBHOOK_ID.c b/src/backend/taler-merchant-httpd_patch-private-webhooks-WEBHOOK_ID.c @@ -26,75 +26,10 @@ #include "taler-merchant-httpd_patch-private-webhooks-WEBHOOK_ID.h" #include "taler-merchant-httpd_helper.h" #include <taler/taler_json_lib.h> -#include "merchant-database/lookup_webhook.h" #include "merchant-database/update_webhook.h" /** - * How often do we retry the simple INSERT database transaction? - */ -#define MAX_RETRIES 3 - - -/** - * Determine the cause of the PATCH failure in more detail and report. - * - * @param connection connection to report on - * @param instance_id instance we are processing - * @param webhook_id ID of the webhook to patch - * @param wb webhook details we failed to set - */ -static enum MHD_Result -determine_cause (struct MHD_Connection *connection, - const char *instance_id, - const char *webhook_id, - const struct TALER_MERCHANTDB_WebhookDetails *wb) -{ - struct TALER_MERCHANTDB_WebhookDetails wpx; - enum GNUNET_DB_QueryStatus qs; - - qs = TALER_MERCHANTDB_lookup_webhook (TMH_db, - instance_id, - webhook_id, - &wpx); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - NULL); - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_MERCHANT_GENERIC_WEBHOOK_UNKNOWN, - webhook_id); - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; /* do below */ - } - - { - enum TALER_ErrorCode ec; - - ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; - TALER_MERCHANTDB_webhook_details_free (&wpx); - GNUNET_break (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE != ec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - ec, - NULL); - } -} - - -/** * PATCH configuration of an existing instance, given its configuration. * * @param rh context of the handler @@ -143,7 +78,6 @@ TMH_private_patch_webhooks_ID (const struct TMH_RequestHandler *rh, : MHD_NO; } - qs = TALER_MERCHANTDB_update_webhook (TMH_db, mi->settings.id, webhook_id, @@ -155,23 +89,26 @@ TMH_private_patch_webhooks_ID (const struct TMH_RequestHandler *rh, { case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - NULL); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + NULL); break; case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); break; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - ret = determine_cause (connection, - mi->settings.id, - webhook_id, - &wb); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_WEBHOOK_UNKNOWN, + webhook_id); break; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: ret = TALER_MHD_reply_static (connection,