merchant

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

commit 68f197e97e45a577f4b0a9a271efdb76bbb203d5
parent 6ff02bc7ea9ca1b39cebf7ac381dfce46f267627
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 11 Apr 2020 18:47:38 +0200

implement payment target exposition in /config, finishes #4939

Diffstat:
Msrc/backend/taler-merchant-httpd_config.c | 38+++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2019 Taler Systems SA + (C) 2019, 2020 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -55,7 +55,37 @@ add_instance (void *cls, json_t *ja = cls; struct MerchantInstance *mi = value; char *url; + json_t *pta; + /* Compile array of all unique wire methods supported by this + instance */ + pta = json_array (); + GNUNET_assert (NULL != pta); + for (struct WireMethod *wm = mi->wm_head; + NULL != wm; + wm = wm->next) + { + int duplicate = GNUNET_NO; + + if (! wm->active) + break; + /* Yes, O(n^2), but really how many bank accounts can an + instance realistically have for this to matter? */ + for (struct WireMethod *pm = mi->wm_head; + pm != wm; + pm = pm->next) + if (0 == strcasecmp (pm->wire_method, + wm->wire_method)) + { + duplicate = GNUNET_YES; + break; + } + if (duplicate) + continue; + GNUNET_assert (0 == + json_array_append_new (pta, + json_string (wm->wire_method))); + } GNUNET_asprintf (&url, "/%s/", mi->id); @@ -64,14 +94,16 @@ add_instance (void *cls, ja, json_pack ( (NULL != mi->tip_exchange) - ? "{s:s, s:s, s:o, s:s}" - : "{s:s, s:s, s:o}", + ? "{s:s, s:s, s:o, s:o, s:s}" + : "{s:s, s:s, s:o, s:o}", "name", mi->name, "backend_base_url", url, "merchant_pub", GNUNET_JSON_from_data_auto (&mi->pubkey), + "payment_targets", + pta, /* optional: */ "tipping_exchange_baseurl", mi->tip_exchange)));