merchant

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

commit 778e1d9d7b589ae0a5a131f3645b5e1a91f081a5
parent 8d24399080fd4e79617bb0284ecbd10058285e29
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Mon,  4 Aug 2025 18:50:28 +0200

adding missing files to git

Diffstat:
Asrc/backenddb/pg_select_donau_instance_by_serial.c | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_donau_instance_by_serial.h | 46++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_donau_instance.c | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_donau_instance.h | 46++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 224 insertions(+), 0 deletions(-)

diff --git a/src/backenddb/pg_select_donau_instance_by_serial.c b/src/backenddb/pg_select_donau_instance_by_serial.c @@ -0,0 +1,60 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_donau_instance_by_serial.c + * @brief Implementation of the select_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_donau_instance_by_serial.h" +#include "taler_merchant_donau.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_select_donau_instance_by_serial (void *cls, + uint64_t serial, + char **donau_url, + uint64_t *charity_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&serial), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_string ("donau_url", donau_url), + GNUNET_PQ_result_spec_uint64 ("charity_id", charity_id), + GNUNET_PQ_result_spec_end + }; + + check_connection (pg); + PREPARE (pg, + "select_donau_instance_by_serial", + "SELECT donau_url, charity_id" + " FROM merchant_donau_instances" + " WHERE donau_instances_serial = $1"); + + return GNUNET_PQ_eval_prepared_singleton_select ( + pg->conn, + "select_donau_instance_by_serial", + params, + rs); +} +\ No newline at end of file diff --git a/src/backenddb/pg_select_donau_instance_by_serial.h b/src/backenddb/pg_select_donau_instance_by_serial.h @@ -0,0 +1,46 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_donau_instance_by_serial.h + * @brief implementation of the select_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#ifndef PG_SELECT_DONAU_INSTANCE_SERIAL_H +#define PG_SELECT_DONAU_INSTANCE_SERIAL_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" +#include "taler_merchant_donau.h" +#include "donau/donau_util.h" + +/** + * Select Donau instance from the database by serial. + * + * @param cls the closure for the database context + * @param serial the serial of the Donau instance to select + * @param[out] donau_url Donau URL + * @param[out] charity_id charity ID + * @return status of the PG + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_donau_instance_by_serial (void *cls, + uint64_t serial, + char **donau_url, + uint64_t *charity_id); + +#endif diff --git a/src/backenddb/pg_update_donau_instance.c b/src/backenddb/pg_update_donau_instance.c @@ -0,0 +1,70 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_donau_instance.c + * @brief Implementation of the update_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "donau/donau_service.h" +#include "pg_update_donau_instance.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_update_donau_instance ( + void *cls, + const char *donau_url, + const struct DONAU_Charity *charity, + const uint64_t charity_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (donau_url), + GNUNET_PQ_query_param_string (charity->name), + GNUNET_PQ_query_param_auto_from_type (&charity->charity_pub), + GNUNET_PQ_query_param_uint64 (&charity_id), + TALER_PQ_query_param_amount_with_currency (pg->conn, + &charity->max_per_year), + TALER_PQ_query_param_amount_with_currency (pg->conn, + &charity->receipts_to_date), + GNUNET_PQ_query_param_uint64 (&charity->current_year), + GNUNET_PQ_query_param_end + }; + + check_connection (pg); + + PREPARE (pg, + "update_existing_donau_instance", + "UPDATE merchant_donau_instances SET" + " charity_name = $2," + " merchant_instance_serial = (SELECT merchant_serial" + " FROM merchant_instances mi" + " WHERE mi.merchant_pub = $3)," + " charity_max_per_year = $5," + " charity_receipts_to_date = $6," + " current_year = $7" + " WHERE" + " charity_id = $4" + " AND donau_url = $1;"); + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_existing_donau_instance", + params); +} +\ No newline at end of file diff --git a/src/backenddb/pg_update_donau_instance.h b/src/backenddb/pg_update_donau_instance.h @@ -0,0 +1,46 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_donau_instance.h + * @brief implementation of the update_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#ifndef PG_UPDATE_DONAU_INSTANCE_H +#define PG_UPDATE_DONAU_INSTANCE_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" +#include "donau/donau_service.h" + +/** + * Update information about a Donau charity instance. + * + * @param cls closure + * @param donau_url URL of the Donau + * @param charity structure containing information about the charity + * @param charity_id unique identifier for the charity + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_update_donau_instance ( + void *cls, + const char *donau_url, + const struct DONAU_Charity *charity, + const uint64_t charity_id); + +#endif