commit 9a27496913724498df3db912ea1cbda6c80f8cc2
parent 81ede40229dc016d18af225646f6f9a1b16bd03a
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 30 Oct 2020 23:38:37 +0100
properly detect if CONTRACT with same order ID already exists as well
Diffstat:
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -218,6 +218,17 @@ execute_transaction (struct TMH_HandlerContext *hc,
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ qs = TMH_db->lookup_order_summary (TMH_db->cls,
+ hc->instance->settings.id,
+ order_id,
+ ×tamp,
+ &order_serial);
+ if (0 != qs)
+ {
+ /* order already exists. */
+ TMH_db->rollback (TMH_db->cls);
+ return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
+ }
/* Setup order */
qs = TMH_db->insert_order (TMH_db->cls,
hc->instance->settings.id,
@@ -226,11 +237,11 @@ execute_transaction (struct TMH_HandlerContext *hc,
pay_deadline,
claim_token,
order);
- /* qs == 0: order already exists. */
+ /* qs == 0: probably instance does not exist. */
if (qs <= 0)
{
TMH_db->rollback (TMH_db->cls);
- return qs;
+ return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
/* Migrate locks from UUIDs to new order: first release old locks */
for (unsigned int i = 0; i<uuids_length; i++)
@@ -508,6 +519,16 @@ execute_order (struct MHD_Connection *connection,
NULL);
}
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ /* should be: contract (!) with same order ID
+ already exists */
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS,
+ order_id);
+ }
+
/* If we have a product that has insufficient quantities,
generate the details for the response. */
if (PRODUCT_OOS_OFFSET >= qs)