merchant

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

commit 116904c7ff6b7b9972c5c77080e0bf7cd9240217
parent aab4d45dfe909afc1f6c2c1bf31143c1ec0f1e1c
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Sun,  8 Oct 2023 22:51:51 +0200

dd 51 work

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 20++++++++++++++++++++
Msrc/backend/taler-merchant-httpd.h | 10++++++++++
Msrc/backend/taler-merchant-httpd_config.c | 15+++++++++++++++
3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -147,6 +147,16 @@ struct GNUNET_CONTAINER_MultiHashMap *TMH_by_id_map; struct GNUNET_TIME_Relative TMH_legal_expiration; /** + * Length of the TMH_cspecs array. + */ +unsigned int TMH_num_cspecs; + +/** + * Rendering specs for currencies. + */ +struct TALER_CurrencySpecification *TMH_cspecs; + +/** * The port we are running on */ static uint16_t port; @@ -2161,6 +2171,16 @@ run (void *cls, GNUNET_SCHEDULER_shutdown (); return; } + + if (GNUNET_OK != + TALER_CONFIG_parse_currencies (cfg, + &TMH_num_cspecs, + &TMH_cspecs)) + { + GNUNET_SCHEDULER_shutdown (); + return; + } + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "merchant", diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h @@ -672,6 +672,16 @@ struct TMH_SuspendedConnection extern char *TMH_currency; /** + * Length of the TMH_cspecs array. + */ +extern unsigned int TMH_num_cspecs; + +/** + * Rendering specs for currencies. + */ +extern struct TALER_CurrencySpecification *TMH_cspecs; + +/** * Inform the auditor for all deposit confirmations (global option) */ extern int TMH_force_audit; diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c @@ -56,9 +56,24 @@ MH_handler_config (struct TMH_RequestHandler *rh, (void) hc; if (NULL == response) { + json_t *specs = json_object (); + + GNUNET_assert (NULL != specs); + for (unsigned int i=0;i<TMH_num_cspecs;i++) + { + const struct TALER_CurrencySpecification *cspec = &TMH_cspecs[i]; + + /* FIXME: filter by currencies with configured exchange? */ + GNUNET_assert (0 == + json_object_set_new (specs, + cspec->currency, + TALER_CONFIG_currency_specs_to_json (cspec))); + } response = TALER_MHD_MAKE_JSON_PACK ( GNUNET_JSON_pack_string ("currency", TMH_currency), + GNUNET_JSON_pack_object_steal ("currencies", + specs), GNUNET_JSON_pack_string ("name", "taler-merchant"), GNUNET_JSON_pack_string ("version",