merchant

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

commit cb854d6fed86ceae81ab9a7944dc8a9c90dfa967
parent 55c2e6392092760b5a3b1d40e363d7f48c3ca8d8
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 24 Mar 2026 00:43:26 +0100

fix some discrepancies in libtalermerchant with respect to actual latest REST API implemented by the server

Diffstat:
Msrc/backend/taler-merchant-httpd_get-templates-TEMPLATE_ID.c | 1-
Msrc/include/taler/taler-merchant/get-private-transfers.h | 8+++++++-
Msrc/lib/merchant_api_get-private-tokenfamilies-TOKEN_FAMILY_SLUG.c | 6++++--
Msrc/lib/merchant_api_get-private-transfers.c | 6+++++-
Msrc/lib/merchant_api_get-private-units-UNIT.c | 47++++++++++++++++-------------------------------
Msrc/lib/merchant_api_get-private-units.c | 62+++++++++++++++++++-------------------------------------------
Msrc/testing/testing_api_cmd_get_transfers.c | 2+-
7 files changed, 52 insertions(+), 80 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-templates-TEMPLATE_ID.c b/src/backend/taler-merchant-httpd_get-templates-TEMPLATE_ID.c @@ -90,7 +90,6 @@ inventory_payload_cleanup (struct InventoryPayloadContext *ipc) ipc->products = NULL; ipc->category_payload = NULL; ipc->unit_payload = NULL; - ipc->category_set.ids = NULL; ipc->category_set.len = 0; } diff --git a/src/include/taler/taler-merchant/get-private-transfers.h b/src/include/taler/taler-merchant/get-private-transfers.h @@ -316,7 +316,7 @@ struct TALER_MERCHANT_GetPrivateTransfersTransferData /** * Serial number of the credit operation in the merchant backend. */ - uint64_t credit_serial; + uint64_t transfer_serial_id; /** * Time of the wire transfer, based on when we received @@ -325,6 +325,12 @@ struct TALER_MERCHANT_GetPrivateTransfersTransferData struct GNUNET_TIME_Timestamp execution_time; /** + * Serial number of the expected transfer in the merchant backend, + * or 0 if not known. + */ + uint64_t expected_transfer_serial_id; + + /** * True if this wire transfer was expected. */ bool expected; diff --git a/src/lib/merchant_api_get-private-tokenfamilies-TOKEN_FAMILY_SLUG.c b/src/lib/merchant_api_get-private-tokenfamilies-TOKEN_FAMILY_SLUG.c @@ -110,8 +110,10 @@ handle_get_token_family_finished (void *cls, &tfgr.details.ok.description), GNUNET_JSON_spec_object_const ("description_i18n", &tfgr.details.ok.description_i18n), - GNUNET_JSON_spec_object_const ("extra_data", - &tfgr.details.ok.extra_data), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_object_const ("extra_data", + &tfgr.details.ok.extra_data), + NULL), GNUNET_JSON_spec_timestamp ("valid_after", &tfgr.details.ok.valid_after), GNUNET_JSON_spec_timestamp ("valid_before", diff --git a/src/lib/merchant_api_get-private-transfers.c b/src/lib/merchant_api_get-private-transfers.c @@ -148,11 +148,15 @@ parse_transfers ( TALER_JSON_spec_web_url ("exchange_url", &td->exchange_url), GNUNET_JSON_spec_uint64 ("transfer_serial_id", - &td->credit_serial), + &td->transfer_serial_id), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_timestamp ("execution_time", &td->execution_time), NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_uint64 ("expected_transfer_serial_id", + &td->expected_transfer_serial_id), + NULL), GNUNET_JSON_spec_bool ("expected", &td->expected), GNUNET_JSON_spec_end () diff --git a/src/lib/merchant_api_get-private-units-UNIT.c b/src/lib/merchant_api_get-private-units-UNIT.c @@ -15,7 +15,7 @@ <http://www.gnu.org/licenses/> */ /** - * @file merchant_api_get-private-units-UNIT-new.c + * @file merchant_api_get-private-units-UNIT.c * @brief Implementation of the GET /private/units/$UNIT request * @author Christian Grothoff */ @@ -84,41 +84,37 @@ parse_unit (const json_t *json, struct TALER_MERCHANT_GetPrivateUnitResponse *ugr) { struct TALER_MERCHANT_UnitEntry *entry = &ugr->details.ok.unit; - const char *unit; - const char *unit_name_long; - const char *unit_name_short; - const json_t *unit_name_long_i18n = NULL; - const json_t *unit_name_short_i18n = NULL; - bool unit_allow_fraction; - bool unit_active; - bool unit_builtin; - uint32_t unit_precision_level; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("unit", - &unit), + &entry->unit), GNUNET_JSON_spec_string ("unit_name_long", - &unit_name_long), + &entry->unit_name_long), GNUNET_JSON_spec_string ("unit_name_short", - &unit_name_short), + &entry->unit_name_short), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_object_const ("unit_name_long_i18n", - &unit_name_long_i18n), + &entry->unit_name_long_i18n), NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_object_const ("unit_name_short_i18n", - &unit_name_short_i18n), + &entry->unit_name_short_i18n), NULL), GNUNET_JSON_spec_bool ("unit_allow_fraction", - &unit_allow_fraction), + &entry->unit_allow_fraction), GNUNET_JSON_spec_uint32 ("unit_precision_level", - &unit_precision_level), + &entry->unit_precision_level), GNUNET_JSON_spec_bool ("unit_active", - &unit_active), + &entry->unit_active), GNUNET_JSON_spec_bool ("unit_builtin", - &unit_builtin), + &entry->unit_builtin), + GNUNET_JSON_spec_uint64 ("unit_serial", + &entry->unit_serial), GNUNET_JSON_spec_end () }; + memset (entry, + 0, + sizeof (*entry)); if (GNUNET_OK != GNUNET_JSON_parse (json, spec, @@ -126,19 +122,8 @@ parse_unit (const json_t *json, NULL)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } - GNUNET_JSON_parse_free (spec); - entry->unit = unit; - entry->unit_name_long = unit_name_long; - entry->unit_name_short = unit_name_short; - entry->unit_name_long_i18n = unit_name_long_i18n; - entry->unit_name_short_i18n = unit_name_short_i18n; - entry->unit_allow_fraction = unit_allow_fraction; - entry->unit_precision_level = unit_precision_level; - entry->unit_active = unit_active; - entry->unit_builtin = unit_builtin; return GNUNET_OK; } @@ -271,4 +256,4 @@ TALER_MERCHANT_get_private_unit_cancel ( } -/* end of merchant_api_get-private-units-UNIT-new.c */ +/* end of merchant_api_get-private-units-UNIT.c */ diff --git a/src/lib/merchant_api_get-private-units.c b/src/lib/merchant_api_get-private-units.c @@ -15,7 +15,7 @@ <http://www.gnu.org/licenses/> */ /** - * @file merchant_api_get-private-units-new.c + * @file merchant_api_get-private-units.c * @brief Implementation of the GET /private/units request * @author Christian Grothoff */ @@ -84,41 +84,37 @@ static enum GNUNET_GenericReturnValue parse_unit_entry (const json_t *value, struct TALER_MERCHANT_UnitEntry *ue) { - const char *unit; - const char *unit_name_long; - const char *unit_name_short; - const json_t *unit_name_long_i18n = NULL; - const json_t *unit_name_short_i18n = NULL; - bool unit_allow_fraction; - bool unit_active; - bool unit_builtin; - uint32_t unit_precision_level; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("unit", - &unit), + &ue->unit), GNUNET_JSON_spec_string ("unit_name_long", - &unit_name_long), + &ue->unit_name_long), GNUNET_JSON_spec_string ("unit_name_short", - &unit_name_short), + &ue->unit_name_short), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_object_const ("unit_name_long_i18n", - &unit_name_long_i18n), + &ue->unit_name_long_i18n), NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_object_const ("unit_name_short_i18n", - &unit_name_short_i18n), + &ue->unit_name_short_i18n), NULL), GNUNET_JSON_spec_bool ("unit_allow_fraction", - &unit_allow_fraction), + &ue->unit_allow_fraction), GNUNET_JSON_spec_uint32 ("unit_precision_level", - &unit_precision_level), + &ue->unit_precision_level), GNUNET_JSON_spec_bool ("unit_active", - &unit_active), + &ue->unit_active), GNUNET_JSON_spec_bool ("unit_builtin", - &unit_builtin), + &ue->unit_builtin), + GNUNET_JSON_spec_uint64 ("unit_serial", + &ue->unit_serial), GNUNET_JSON_spec_end () }; + memset (ue, + 0, + sizeof (*ue)); if (GNUNET_OK != GNUNET_JSON_parse (value, spec, @@ -126,19 +122,8 @@ parse_unit_entry (const json_t *value, NULL)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } - GNUNET_JSON_parse_free (spec); - ue->unit = unit; - ue->unit_name_long = unit_name_long; - ue->unit_name_short = unit_name_short; - ue->unit_name_long_i18n = unit_name_long_i18n; - ue->unit_name_short_i18n = unit_name_short_i18n; - ue->unit_allow_fraction = unit_allow_fraction; - ue->unit_precision_level = unit_precision_level; - ue->unit_active = unit_active; - ue->unit_builtin = unit_builtin; return GNUNET_OK; } @@ -156,9 +141,8 @@ parse_units (const json_t *json, const json_t *units, struct TALER_MERCHANT_GetPrivateUnitsHandle *gpuh) { - size_t len; + size_t len = json_array_size (units); - len = json_array_size (units); if (len > MAX_UNITS) { GNUNET_break_op (0); @@ -183,16 +167,8 @@ parse_units (const json_t *json, struct TALER_MERCHANT_GetPrivateUnitsResponse ugr = { .hr.http_status = MHD_HTTP_OK, .hr.reply = json, - .details = { - .ok = { - .units = entries, - .units_length = (unsigned int) len - } - - - } - - + .details.ok.units = entries, + .details.ok.units_length = (unsigned int) len }; gpuh->cb (gpuh->cb_cls, @@ -342,4 +318,4 @@ TALER_MERCHANT_get_private_units_cancel ( } -/* end of merchant_api_get-private-units-new.c */ +/* end of merchant_api_get-private-units.c */ diff --git a/src/testing/testing_api_cmd_get_transfers.c b/src/testing/testing_api_cmd_get_transfers.c @@ -155,7 +155,7 @@ get_transfers_cb ( } TALER_TESTING_cmd_merchant_post_transfer_set_serial ( (struct TALER_TESTING_Command *) transfer_cmd, - transfer->credit_serial); + transfer->transfer_serial_id); } { const struct TALER_FullPayto *payto_uri;