merchant

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

commit 6e51714a525a5c338b32684a8ca99baffe379158
parent 3a063e36ea53904672a6889856c2dddee019258e
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Sat, 15 Mar 2025 19:56:22 +0100

changes to db for the donau order

Diffstat:
Msrc/backenddb/Makefile.am | 1+
Msrc/backenddb/merchant-0014.sql | 17++++++++++++++++-
Asrc/backenddb/pg_insert_order_budis.c | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_order_budis.h | 44++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am @@ -112,6 +112,7 @@ libtaler_plugin_merchantdb_postgres_la_SOURCES = \ pg_insert_issued_token.h pg_insert_issued_token.c \ pg_insert_login_token.h pg_insert_login_token.c \ pg_insert_order.h pg_insert_order.c \ + pg_insert_order_budis.h pg_insert_order_budis.c \ pg_insert_order_lock.h pg_insert_order_lock.c \ pg_insert_otp.h pg_insert_otp.c \ pg_insert_pending_webhook.h pg_insert_pending_webhook.c \ diff --git a/src/backenddb/merchant-0014.sql b/src/backenddb/merchant-0014.sql @@ -14,7 +14,7 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- --- @file merchant-0012.sql +-- @file merchant-0014.sql -- @brief Create table to store donau related information -- @author Bohdan Potuzhnyi -- @author Vlada Svirsh @@ -69,5 +69,20 @@ COMMENT ON COLUMN merchant_donau_instances.charity_receipts_to_date COMMENT ON COLUMN merchant_donau_instances.current_year IS 'The current year for tracking donations for this instance, stored as an 8-byte integer'; +CREATE TABLE IF NOT EXISTS merchant_order_donau +(order_donau_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY + ,order_id TEXT NOT NULL + REFERENCES merchant_orders (order_id) ON DELETE CASCADE + ,donau_budis TEXT NOT NULL +); + +COMMENT ON TABLE merchant_order_donau + IS 'Table linking merchant orders with Donau BUDIS information'; +COMMENT ON COLUMN merchant_order_donau.order_donau_serial + IS 'Unique serial identifier for Donau order linkage'; +COMMENT ON COLUMN merchant_order_donau.order_id + IS 'Foreign key linking to the corresponding merchant order'; +COMMENT ON COLUMN merchant_order_donau.donau_budis + IS 'Donau BUDIs json associated with the order'; COMMIT; \ No newline at end of file diff --git a/src/backenddb/pg_insert_order_budis.c b/src/backenddb/pg_insert_order_budis.c @@ -0,0 +1,56 @@ +/* + 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_insert_order_budis.c + * @brief Implementation of the insert_order_budis 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_insert_order_budis.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_insert_order_budis ( + void *cls, + const char *order_id, + const json_t *donau_budis) +{ + struct PostgresClosure *pg = cls; + + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (order_id), + TALER_PQ_query_param_json (donau_budis), + GNUNET_PQ_query_param_end + }; + + check_connection (pg); + + PREPARE (pg, + "insert_order_budis", + "INSERT INTO merchant_order_donau (order_id, donau_budis)" + " VALUES ($1, $2)"); + + /* Execute the prepared statement */ + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_order_budis", + params); +} diff --git a/src/backenddb/pg_insert_order_budis.h b/src/backenddb/pg_insert_order_budis.h @@ -0,0 +1,44 @@ +/* + 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_insert_order_budis.h + * @brief Declaration of the insert_order_budis function for Postgres + * @author Bohdan Potuzhnyi + */ + +#ifndef PG_INSERT_ORDER_BUDIS_H +#define PG_INSERT_ORDER_BUDIS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Insert Donau BUDIS info for a given order_id into the merchant_order_donau table. + * + * @param cls closure (the Postgres handle) + * @param order_id the merchant order_id to update + * @param donau_budis JSON describing the BUDIS data for Donau + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_insert_order_budis ( + void *cls, + const char *order_id, + const json_t *donau_budis); + +#endif