merchant

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

commit db832779fab541abe13183885632a370242fdda9
parent bf0eeb5845803f9c47f03d6a741b22ee0b6f742b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  9 Oct 2026 23:04:35 +0200

validate credit_facade works for the account before persisting in DB

Diffstat:
Msrc/backend/taler-merchant-httpd_patch-private-accounts-H_WIRE.c | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+), 0 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_patch-private-accounts-H_WIRE.c b/src/backend/taler-merchant-httpd_patch-private-accounts-H_WIRE.c @@ -27,6 +27,8 @@ #include "taler-merchant-httpd_helper.h" #include <taler/taler_json_lib.h> #include "taler-merchant-httpd_mfa.h" +#include "taler/taler_merchant_bank_lib.h" +#include "merchant-database/get_account.h" #include "merchant-database/update_account.h" @@ -101,6 +103,65 @@ TMH_private_patch_accounts_ID (const struct TMH_RequestHandler *rh, TALER_EC_GENERIC_PARAMETER_MALFORMED, "extra_wire_subject_metadata"); } + if (NULL != cfu) + { + /* The credit facade URL and the (new or preserved) credentials + must be usable together, as taler-merchant-wirewatch refuses + to start with any unusable active account configuration. */ + struct TALER_MERCHANTDB_AccountDetails ad = { 0 }; + const json_t *ecfc = cfc; + struct TALER_MERCHANT_BANK_AuthenticationData auth; + bool valid; + + if (NULL == ecfc) + { + qs = TALER_MERCHANTDB_get_account (TMH_db, + mi->settings.id, + &h_wire, + &ad); + if (0 > qs) + { + GNUNET_break (0); + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "get_account"); + } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + h_wire_s); + } + ecfc = ad.credit_facade_credentials; + } + valid = ( (NULL != ecfc) && + (GNUNET_OK == + TALER_MERCHANT_BANK_auth_parse_json (ecfc, + cfu, + &auth)) ); + if (valid) + TALER_MERCHANT_BANK_auth_free (&auth); + json_decref (ad.credit_facade_credentials); + GNUNET_free (ad.credit_facade_url); + GNUNET_free (ad.extra_wire_subject_metadata); + GNUNET_free (ad.payto_uri.full_payto); + if (! valid) + { + GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "credit_facade_url or credit_facade_credentials"); + } + } qs = TALER_MERCHANTDB_update_account (TMH_db, mi->settings.id,