diff options
Diffstat (limited to 'src/backenddb')
-rw-r--r-- | src/backenddb/pg_lookup_order_by_fulfillment.c | 12 | ||||
-rw-r--r-- | src/backenddb/pg_lookup_order_by_fulfillment.h | 2 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/backenddb/pg_lookup_order_by_fulfillment.c b/src/backenddb/pg_lookup_order_by_fulfillment.c index 0e9eba4a..291bd857 100644 --- a/src/backenddb/pg_lookup_order_by_fulfillment.c +++ b/src/backenddb/pg_lookup_order_by_fulfillment.c @@ -30,6 +30,7 @@ TMH_PG_lookup_order_by_fulfillment (void *cls, const char *instance_id, const char *fulfillment_url, const char *session_id, + bool allow_refunded_for_repurchase, char **order_id) { struct PostgresClosure *pg = cls; @@ -37,6 +38,7 @@ TMH_PG_lookup_order_by_fulfillment (void *cls, GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (fulfillment_url), GNUNET_PQ_query_param_string (session_id), + GNUNET_PQ_query_param_bool (allow_refunded_for_repurchase), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -49,14 +51,18 @@ TMH_PG_lookup_order_by_fulfillment (void *cls, PREPARE (pg, "lookup_order_by_fulfillment", "SELECT" - " order_id" - " FROM merchant_contract_terms" + " mct.order_id" + " FROM merchant_contract_terms mct" + " LEFT JOIN merchant_refunds mref" + " USING (order_serial)" " WHERE fulfillment_url=$2" " AND session_id=$3" " AND merchant_serial=" " (SELECT merchant_serial" " FROM merchant_instances" - " WHERE merchant_id=$1)"); + " WHERE merchant_id=$1)" + " AND ((CAST($4 AS BOOL)) OR" + " mref.refund_serial IS NULL)"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "lookup_order_by_fulfillment", diff --git a/src/backenddb/pg_lookup_order_by_fulfillment.h b/src/backenddb/pg_lookup_order_by_fulfillment.h index 883ff4b9..44e96756 100644 --- a/src/backenddb/pg_lookup_order_by_fulfillment.h +++ b/src/backenddb/pg_lookup_order_by_fulfillment.h @@ -33,6 +33,7 @@ * @param fulfillment_url URL that canonically identifies the resource * being paid for * @param session_id session id + * @param allow_refunded_for_repurchase true to include refunded orders in repurchase detection * @param[out] order_id where to store the order ID that was used when * paying for the resource URL * @return transaction status @@ -42,6 +43,7 @@ TMH_PG_lookup_order_by_fulfillment (void *cls, const char *instance_id, const char *fulfillment_url, const char *session_id, + bool allow_refunded_for_repurchase, char **order_id); #endif diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 2b9368f1..53902b3d 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -1811,6 +1811,7 @@ test_lookup_order_by_fulfillment (const struct InstanceData *instance, instance->instance.id, fulfillment_url, session_id, + false, &order_id)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -2165,6 +2166,7 @@ run_test_orders (struct TestOrders_Closure *cls) cls->instance.instance.id, "fulfillment_url", "test_orders_session", + false, &order_id)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |