merchant

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

commit facdf0bbab81a9857ab14aec3f6f0a8565f85ed0
parent 71f18bfdb0eaa8d68c09a52a8a3197b23d03b8a9
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Mon, 24 Mar 2025 22:31:26 +0100

adding the call of the insert budis into the DB and small fixes

Diffstat:
Msrc/backend/taler-merchant-httpd_post-orders-ID-pay.c | 26+++++++++++++++++++++++++-
Msrc/backenddb/merchant-0015.sql | 6+++---
Msrc/backenddb/pg_insert_order_budis.c | 6++++--
Msrc/include/taler_merchantdb_plugin.h | 10++++++++++
4 files changed, 42 insertions(+), 6 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 @@ -2437,7 +2437,31 @@ phase_execute_pay_transaction (struct PayContext *pc) // FIXME: insert donau blinded inputs (into DB here!), // idempotency: if already exists, no problem! // I believe it must be the parse_wallet_data.donau.budikeypairs - + if (NULL != pc->parse_wallet_data.donau.budikeypairs) + { + enum GNUNET_DB_QueryStatus qs; + qs = TMH_db->insert_order_budis (TMH_db->cls, + pc->order_id, + pc->parse_wallet_data.donau.budikeypairs); + if (qs < 0) + { + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Order BUDIs already present, ignoring.\n"); + } + else + { + TMH_db->rollback (TMH_db->cls); + pay_end (pc, + TALER_MHD_reply_with_error (pc->connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_order_budis")); + return; + } + } + } TMH_notify_order_change (hc->instance, TMH_OSF_CLAIMED | TMH_OSF_PAID, diff --git a/src/backenddb/merchant-0015.sql b/src/backenddb/merchant-0015.sql @@ -71,8 +71,8 @@ COMMENT ON COLUMN merchant_donau_instances.current_year 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 + ,order_serial BIGINT NOT NULL + REFERENCES merchant_orders (order_serial) ON DELETE CASCADE ,donau_budis TEXT NOT NULL ); @@ -80,7 +80,7 @@ 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 +COMMENT ON COLUMN merchant_order_donau.order_serial 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'; diff --git a/src/backenddb/pg_insert_order_budis.c b/src/backenddb/pg_insert_order_budis.c @@ -46,8 +46,10 @@ TMH_PG_insert_order_budis ( PREPARE (pg, "insert_order_budis", - "INSERT INTO merchant_order_donau (order_id, donau_budis)" - " VALUES ($1, $2)"); + "INSERT INTO merchant_order_donau (order_serial, donau_budis) " + "SELECT order_serial, $2 " + "FROM merchant_orders " + "WHERE order_id = $1"); /* Execute the prepared statement */ return GNUNET_PQ_eval_prepared_non_select (pg->conn, diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -2164,6 +2164,16 @@ struct TALER_MERCHANTDB_Plugin /** + * Adds BUDIs to the table matching the order + * + * FIXME: Add all params + */ + enum GNUNET_DB_QueryStatus + (*insert_order_budis)(void *cls, + const char *order_id, + const json_t *donau_budis); + + /** * Release an inventory lock by UUID. Releases ALL stocks locked under * the given UUID. *