commit 57ff3af065b6e3e8508d5cfaa90d32b8262bcec2
parent 1218621cdeaa505377938ac8cb8b0b5149508b0f
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Fri, 14 Mar 2025 17:11:19 +0100
adding the donau related entries for the api input
Diffstat:
1 file changed, 74 insertions(+), 0 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -117,6 +117,10 @@ enum PayPhase
PP_PAY_TRANSACTION,
// FIXME: new (optional) phase for DONAU interaction here.
+ /**
+ * Communicate with DONAU to generate a donation receipt from the donor BUDIs.
+ */
+ PP_GENERATE_DONATION_RECEIPT,
/**
* Notify other processes about successful payment.
@@ -367,6 +371,25 @@ struct ExchangeGroup
};
+struct DonauData
+{
+ /**
+ * The user-selected Donau URL.
+ */
+ char *donau_url;
+
+ /**
+ * The donation year, as parsed from "year".
+ */
+ uint64_t donation_year;
+
+ /**
+ * The original BUDI key-pairs array from the donor
+ * to be used for the receipt creation.
+ */
+ const json_t *budikeypairs;
+};
+
/**
* Information we keep for an individual call to the /pay handler.
*/
@@ -504,6 +527,11 @@ struct PayContext
*/
struct GNUNET_HashCode h_wallet_data;
+ /**
+ * Donau related information
+ */
+ struct DonauData donau;
+
} parse_wallet_data;
/**
@@ -3510,6 +3538,10 @@ static void
phase_parse_wallet_data (struct PayContext *pc)
{
const json_t *tokens_evs;
+ const json_t *budikeypairs = NULL;
+ const char *donau_url_tmp = NULL;
+ uint64_t donation_year_tmp = 0;
+
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_int64 ("choice_index",
@@ -3519,6 +3551,24 @@ phase_parse_wallet_data (struct PayContext *pc)
GNUNET_JSON_spec_array_const ("tokens_evs",
&tokens_evs),
NULL),
+
+ /* FIELDS for DONAU ------------------------------------- */
+ /* "donau_url" is optional (a JSON string) */
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("donau_url",
+ &donau_url_tmp),
+ NULL),
+ /* "donation_year" is optional (parsed as uint64_t) */
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_uint64 ("year",
+ &donation_year_tmp),
+ NULL),
+ /* "budikeypairs" is optional (a JSON array) */
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_array_const ("budikeypairs",
+ &budikeypairs),
+ NULL),
+ /* ---------------------------------------------------------- */
// FIXME: extend spec for wallet to submit
// - URL of selected donau
// - year
@@ -3621,6 +3671,30 @@ phase_parse_wallet_data (struct PayContext *pc)
}
}
+ pc->parse_wallet_data.donau.donau_url = NULL;
+ {
+ if (NULL != donau_url_tmp)
+ pc->parse_wallet_data.donau.donau_url = GNUNET_strdup (donau_url_tmp);
+
+ //FIXME: Probably some error handling could happen here
+ }
+
+ pc->parse_wallet_data.donau.donation_year = 0;
+ {
+ pc->parse_wallet_data.donau.donation_year = donation_year_tmp;
+
+ //FIXME: What if the url is set but the year is not?
+ // add error throwing
+
+ }
+
+ pc->parse_wallet_data.donau.budikeypairs = NULL;
+ {
+ pc->parse_wallet_data.donau.budikeypairs = budikeypairs;
+
+ //FIXME: What if the url is set but the budis not?
+ }
+
TALER_json_hash (pc->parse_pay.wallet_data,
&pc->parse_wallet_data.h_wallet_data);