commit af85f31619b4be1eed5f0575f13d26d81db37e1f
parent c582f423500e9a914990e4840479f5da88b7dcf5
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Wed, 23 Jul 2025 12:51:18 +0200
fixme from post orders
Diffstat:
2 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -2421,7 +2421,7 @@ phase_select_wire_method (struct OrderContext *oc)
const struct TALER_Amount *ea;
struct WireMethodCandidate *best = NULL;
unsigned int max_choices = 0;
- unsigned int want_choices;
+ unsigned int want_choices = 0;
for (struct WireMethodCandidate *wmc = oc->add_payment_details.wmc_head;
NULL != wmc;
@@ -3226,21 +3226,19 @@ phase_merge_inventory (struct OrderContext *oc)
* Callback function that is called for each donau instance.
* It simply adds the provided donau_url to the json.
*/
-/* FIXME: Change the function to postgresql to only receive back the donau_url,
- * and maybe charity max per year so we can compare it with amount from the output*/
static void
add_donau_url (void *cls,
const char *donau_url,
- const char *charity_name,
- const struct DONAU_CharityPublicKeyP *charity_pub_key,
- uint64_t charity_id,
- const struct TALER_Amount *charity_max_per_year,
- const struct TALER_Amount *charity_receipts_to_date,
- int64_t current_year,
- const json_t *donau_keys_json)
+ const struct TALER_Amount *charity_max_per_year)
{
struct TALER_MERCHANT_ContractOutput *output = cls;
+ if ( (NULL == charity_max_per_year) ||
+ (GNUNET_OK !=
+ TALER_amount_cmp_currency (&output->details.donation_receipt.amount,
+ charity_max_per_year)) )
+ return;
+
GNUNET_array_append (output->details.donation_receipt.donau_urls,
output->details.donation_receipt.donau_urls_len,
GNUNET_strdup (donau_url));
@@ -3248,16 +3246,16 @@ add_donau_url (void *cls,
static void
-parse_donau_instances (struct OrderContext *oc,
- struct TALER_MERCHANT_ContractOutput *output)
+add_donau_output (struct OrderContext *oc,
+ struct TALER_MERCHANT_ContractOutput *output)
{
enum GNUNET_DB_QueryStatus qs;
/* Invoke the database call, accumulating URLs in a JSON array */
- /* FIXME: select_donau_instances by currency */
- qs = TMH_db->select_donau_instances (TMH_db->cls,
- &add_donau_url,
- output);
+ qs = TMH_db->select_donau_instances_filtered (
+ TMH_db->cls,
+ &add_donau_url,
+ output);
/* REVIEW: If no switch */
if (qs < 0)
@@ -3474,17 +3472,9 @@ phase_parse_choices (struct OrderContext *oc)
case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT:
output.details.donation_receipt.amount = choice->amount;
#ifdef HAVE_DONAU_DONAU_SERVICE_H
- /* FIXME: Change to fetch and move to new phase */
- /* filter by currency */
- parse_donau_instances (oc,
- &output);
+ add_donau_output (oc,
+ &output);
#endif
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Output details donation receipt donau urls %p\n",
- output.details.donation_receipt.donau_urls);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Output details donation receipt donau urls len %u\n",
- output.details.donation_receipt.donau_urls_len);
GNUNET_array_append (choice->outputs,
choice->outputs_len,
diff --git a/src/backenddb/pg_select_donau_instances_filtered.h b/src/backenddb/pg_select_donau_instances_filtered.h
@@ -14,13 +14,13 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file backenddb/pg_select_donau_instances.h
+ * @file backenddb/pg_select_donau_instances_filtered.h
* @brief implementation of the select_donau_instance function for Postgres
* @author Bohdan Potuzhnyi
* @author Vlada Svirsh
*/
-#ifndef PG_SELECT_DONAU_INSTANCE_H
-#define PG_SELECT_DONAU_INSTANCE_H
+#ifndef PG_SELECT_DONAU_INSTANCE_FILTERED_H
+#define PG_SELECT_DONAU_INSTANCE_FILTERED_H
#include <taler/taler_util.h>
#include <taler/taler_json_lib.h>