merchant

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

commit c176ce9d0402195ee19a1bcae792ee2ccbd33e3b
parent fc27666623c28fedf272495881ee63d7580cd589
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 12 Apr 2023 15:44:47 +0200

add wirewatch CRU(D) functions to merchant DB API

Diffstat:
Msrc/backenddb/Makefile.am | 3+++
Asrc/backenddb/pg_insert_wirewatch_progress.c | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_wirewatch_progress.h | 44++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_wirewatch_progress.c | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_wirewatch_progress.h | 44++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_wirewatch_progress.c | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_wirewatch_progress.h | 44++++++++++++++++++++++++++++++++++++++++++++
Msrc/backenddb/plugin_merchantdb_postgres.c | 9+++++++++
Msrc/include/taler_merchantdb_plugin.h | 43+++++++++++++++++++++++++++++++++++++++++++
9 files changed, 347 insertions(+), 0 deletions(-)

diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am @@ -52,6 +52,9 @@ libtalermerchantdb_la_LDFLAGS = \ -no-undefined libtaler_plugin_merchantdb_postgres_la_SOURCES = \ + pg_insert_wirewatch_progress.h pg_insert_wirewatch_progress.c \ + pg_update_wirewatch_progress.h pg_update_wirewatch_progress.c \ + pg_select_wirewatch_progress.h pg_select_wirewatch_progress.c \ pg_lookup_transfers.h pg_lookup_transfers.c \ plugin_merchantdb_postgres.c pg_helper.h libtaler_plugin_merchantdb_postgres_la_LIBADD = \ diff --git a/src/backenddb/pg_insert_wirewatch_progress.c b/src/backenddb/pg_insert_wirewatch_progress.c @@ -0,0 +1,53 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_insert_wirewatch_progress.c + * @brief Implementation of the insert_wirewatch_progress function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_insert_wirewatch_progress.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_insert_wirewatch_progress ( + void *cls, + const char *section, + uint64_t last_serial) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (section), + GNUNET_PQ_query_param_uint64 (&last_serial), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "insert_wirewatch_progress", + "INSERT INTO merchant_wirewatch" + " (account_section" + " ,last_bank_serial)" + " VALUES" + " ($1,$2);"); + check_connection (pg); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_wirewatch_progress", + params); +} diff --git a/src/backenddb/pg_insert_wirewatch_progress.h b/src/backenddb/pg_insert_wirewatch_progress.h @@ -0,0 +1,44 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_insert_wirewatch_progress.h + * @brief implementation of the insert_wirewatch_progress function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_INSERT_WIREWATCH_PROGRESS_H +#define PG_INSERT_WIREWATCH_PROGRESS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include <taler/taler_merchantdb_plugin.h> + + +/** + * Insert information about progress made by taler-merchant-wirewatch. + * + * @param cls closure + * @param section configuration section of the taler-merchant-wirewatch + * @param last_serial last serial imported from the bank + * @return transaction status + */ +enum GNUNET_DB_QueryStatus +TMH_PG_insert_wirewatch_progress ( + void *cls, + const char *section, + uint64_t last_serial); + + +#endif diff --git a/src/backenddb/pg_select_wirewatch_progress.c b/src/backenddb/pg_select_wirewatch_progress.c @@ -0,0 +1,56 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_wirewatch_progress.c + * @brief Implementation of the select_wirewatch_progress function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_wirewatch_progress.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_select_wirewatch_progress ( + void *cls, + const char *section, + uint64_t *last_serial) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (section), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("last_bank_serial", + last_serial), + GNUNET_PQ_result_spec_end + }; + + PREPARE (pg, + "select_wirewatch_progress", + "SELECT last_bank_serial" + " FROM merchant_wirewatch" + " WHERE account_section=$1"); + check_connection (pg); + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "select_wirewatch_progress", + params, + rs); +} diff --git a/src/backenddb/pg_select_wirewatch_progress.h b/src/backenddb/pg_select_wirewatch_progress.h @@ -0,0 +1,44 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_wirewatch_progress.h + * @brief implementation of the select_wirewatch_progress function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_WIREWATCH_PROGRESS_H +#define PG_SELECT_WIREWATCH_PROGRESS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include <taler/taler_merchantdb_plugin.h> + + +/** + * Select information about progress made by taler-merchant-wirewatch. + * + * @param cls closure + * @param section configuration section of the taler-merchant-wirewatch + * @param[out] last_serial set to last serial imported from the bank + * @return transaction status + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_wirewatch_progress ( + void *cls, + const char *section, + uint64_t *last_serial); + + +#endif diff --git a/src/backenddb/pg_update_wirewatch_progress.c b/src/backenddb/pg_update_wirewatch_progress.c @@ -0,0 +1,51 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_wirewatch_progress.c + * @brief Implementation of the update_wirewatch_progress function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_update_wirewatch_progress.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_update_wirewatch_progress ( + void *cls, + const char *section, + uint64_t last_serial) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (section), + GNUNET_PQ_query_param_uint64 (&last_serial), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "update_wirewatch_progress", + "UPDATE merchant_wirewatch" + " SET last_bank_serial=$2" + " WHERE account_section=$1"); + check_connection (pg); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_wirewatch_progress", + params); +} diff --git a/src/backenddb/pg_update_wirewatch_progress.h b/src/backenddb/pg_update_wirewatch_progress.h @@ -0,0 +1,44 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_wirewatch_progress.h + * @brief implementation of the update_wirewatch_progress function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_UPDATE_WIREWATCH_PROGRESS_H +#define PG_UPDATE_WIREWATCH_PROGRESS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include <taler/taler_merchantdb_plugin.h> + + +/** + * Update information about progress made by taler-merchant-wirewatch. + * + * @param cls closure + * @param section configuration section of the taler-merchant-wirewatch + * @param last_serial last serial imported from the bank + * @return transaction status + */ +enum GNUNET_DB_QueryStatus +TMH_PG_update_wirewatch_progress ( + void *cls, + const char *section, + uint64_t last_serial); + + +#endif diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -31,6 +31,9 @@ #include "taler_merchantdb_plugin.h" #include "pg_helper.h" #include "pg_lookup_transfers.h" +#include "pg_insert_wirewatch_progress.h" +#include "pg_update_wirewatch_progress.h" +#include "pg_select_wirewatch_progress.h" /** @@ -10201,6 +10204,12 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) plugin->lookup_transfer_details = &postgres_lookup_transfer_details; plugin->lookup_transfers = &TMH_PG_lookup_transfers; + plugin->insert_wirewatch_progress + = &TMH_PG_insert_wirewatch_progress; + plugin->update_wirewatch_progress + = &TMH_PG_update_wirewatch_progress; + plugin->select_wirewatch_progress + = &TMH_PG_select_wirewatch_progress; plugin->store_wire_fee_by_exchange = &postgres_store_wire_fee_by_exchange; plugin->insert_reserve = &postgres_insert_reserve; plugin->activate_reserve = &postgres_activate_reserve; diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -1999,6 +1999,49 @@ struct TALER_MERCHANTDB_Plugin char **order_id); /** + * Insert information about progress made by taler-merchant-wirewatch. + * + * @param cls closure + * @param section configuration section of the taler-merchant-wirewatch + * @param last_serial last serial imported from the bank + * @return transaction status + */ + enum GNUNET_DB_QueryStatus + (*insert_wirewatch_progress)( + void *cls, + const char *section, + uint64_t last_serial); + + /** + * Update information about progress made by taler-merchant-wirewatch. + * + * @param cls closure + * @param section configuration section of the taler-merchant-wirewatch + * @param last_serial last serial imported from the bank + * @return transaction status + */ + enum GNUNET_DB_QueryStatus + (*update_wirewatch_progress)( + void *cls, + const char *section, + uint64_t last_serial); + + /** + * Select information about progress made by taler-merchant-wirewatch. + * + * @param cls closure + * @param section configuration section of the taler-merchant-wirewatch + * @param[out] last_serial set to last serial imported from the bank + * @return transaction status + */ + enum GNUNET_DB_QueryStatus + (*select_wirewatch_progress)( + void *cls, + const char *section, + uint64_t *last_serial); + + + /** * Insert information about a wire transfer the merchant has received. * * @param cls closure