[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 115/277: misc. fixes
From: |
gnunet |
Subject: |
[taler-merchant] 115/277: misc. fixes |
Date: |
Sun, 05 Jul 2020 20:50:28 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit dc6a6c0ad87a34198a49ea31b39c2eb2bd1e0acb
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 17 22:52:27 2020 +0200
misc. fixes
---
src/backend/taler-merchant-httpd.c | 2 +-
src/backend/taler-merchant-httpd.h | 9 +-
src/backend/taler-merchant-httpd_exchanges.c | 9 ++
.../taler-merchant-httpd_private-post-orders.c | 3 +-
src/backenddb/merchant-0001.sql | 2 +-
src/backenddb/plugin_merchantdb_postgres.c | 136 ++++++++++-----------
src/lib/merchant_api_post_orders.c | 4 +-
src/testing/test_merchant_api.c | 4 +-
8 files changed, 92 insertions(+), 77 deletions(-)
diff --git a/src/backend/taler-merchant-httpd.c
b/src/backend/taler-merchant-httpd.c
index e364011..b280386 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -1077,7 +1077,7 @@ url_handler (void *cls,
else
{
infix_strlen = slash - infix_url;
- suffix_url = slash;
+ suffix_url = slash + 1; /* skip the '/' */
suffix_strlen = strlen (suffix_url);
}
hc->infix = GNUNET_strndup (infix_url,
diff --git a/src/backend/taler-merchant-httpd.h
b/src/backend/taler-merchant-httpd.h
index ceb7dfe..7e1090d 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -151,7 +151,11 @@ struct TMH_RequestHandler
{
/**
- * URL prefix the handler is for.
+ * URL prefix the handler is for, includes the '/',
+ * so "/orders" or "/products". Does *not* include
+ * "/private", that is controlled by the array in which
+ * the handler is defined. Must not contain any
+ * '/' except for the leading '/'.
*/
const char *url_prefix;
@@ -168,7 +172,8 @@ struct TMH_RequestHandler
bool skip_instance;
/**
- * URL suffix the handler is for.
+ * URL suffix the handler is for, excludes the '/',
+ * so "pay" or "claim", not "/pay".
*/
const char *url_suffix;
diff --git a/src/backend/taler-merchant-httpd_exchanges.c
b/src/backend/taler-merchant-httpd_exchanges.c
index ef5bde9..fe4085d 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -498,6 +498,7 @@ get_wire_fees (struct Exchange *exchange,
for (struct FeesByWireMethod *fbw = exchange->wire_fees_head;
NULL != fbw;
fbw = fbw->next)
+ {
if (0 == strcasecmp (fbw->wire_method,
wire_method) )
{
@@ -512,6 +513,10 @@ get_wire_fees (struct Exchange *exchange,
}
return af;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Exchange supports `%s' as a wire method (but we do not use
that one)\n",
+ fbw->wire_method);
+ }
return NULL;
}
@@ -551,6 +556,9 @@ process_find_operations (struct Exchange *exchange)
if (NULL == af)
{
need_wire = GNUNET_YES;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Exchange does not support `%s' wire method (will retry
later)\n",
+ fo->wire_method);
continue;
}
if (af->start_date.abs_value_us > now.abs_value_us)
@@ -688,6 +696,7 @@ handle_wire_data (void *cls,
exchange->wire_retry_delay = RETRY_BACKOFF (exchange->wire_retry_delay);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Exchange does not support our wire method. Retrying in %s\n",
+
GNUNET_STRINGS_relative_time_to_string (
exchange->wire_retry_delay,
GNUNET_YES));
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c
b/src/backend/taler-merchant-httpd_private-post-orders.c
index e6af258..7c6a0c3 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -930,12 +930,13 @@ TMH_private_post_orders (const struct TMH_RequestHandler
*rh,
struct TMH_HandlerContext *hc)
{
json_t *order;
- const char *payment_target;
+ const char *payment_target = NULL;
unsigned int ips_len = 0;
struct InventoryProduct *ips = NULL;
unsigned int uuids_len = 0;
struct GNUNET_Uuid *uuids = NULL;
+ (void) rh;
order = json_object_get (hc->request_body,
"order");
if (NULL == order)
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index 9eb60e5..5d50280 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -236,7 +236,7 @@ CREATE TABLE IF NOT EXISTS merchant_contract_terms
,paid BOOLEAN DEFAULT FALSE NOT NULL
,wired BOOLEAN DEFAULT FALSE NOT NULL
,fulfillment_url VARCHAR NOT NULL
- ,session_id VARCHAR NOT NULL
+ ,session_id VARCHAR DEFAULT '' NOT NULL
,UNIQUE (merchant_serial, order_id)
,UNIQUE (merchant_serial, h_contract_terms)
);
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index 8c1646a..c69507d 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -3646,7 +3646,6 @@ postgres_lookup_transfers (void *cls,
by_time = ( (before.abs_value_us !=
GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) ||
(after.abs_value_us != GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us)
);
-
check_connection (pg);
GNUNET_snprintf (stmt,
sizeof (stmt),
@@ -3657,8 +3656,6 @@ postgres_lookup_transfers (void *cls,
params = (by_time)
? ( (NULL != payto_uri) ? params_payto_et : params_et)
: ( (NULL != payto_uri) ? params_payto : params_none);
-
- // FIXME: write SQL (_desc-variant!)
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
stmt,
params,
@@ -3670,6 +3667,58 @@ postgres_lookup_transfers (void *cls,
}
+/**
+ * Store information about wire fees charged by an exchange,
+ * including signature (so we have proof).
+ *
+ * @param cls closure
+ * @paramm exchange_pub public key of the exchange
+ * @param h_wire_method hash of wire method
+ * @param wire_fee wire fee charged
+ * @param closing_fee closing fee charged (irrelevant for us,
+ * but needed to check signature)
+ * @param start_date start of fee being used
+ * @param end_date end of fee being used
+ * @param exchange_sig signature of exchange over fee structure
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_store_wire_fee_by_exchange (
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct GNUNET_HashCode *h_wire_method,
+ const struct TALER_Amount *wire_fee,
+ const struct TALER_Amount *closing_fee,
+ struct GNUNET_TIME_Absolute start_date,
+ struct GNUNET_TIME_Absolute end_date,
+ const struct
+ TALER_MasterSignatureP *master_sig)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (master_pub),
+ GNUNET_PQ_query_param_auto_from_type (h_wire_method),
+ TALER_PQ_query_param_amount (wire_fee),
+ TALER_PQ_query_param_amount (closing_fee),
+ GNUNET_PQ_query_param_absolute_time (&start_date),
+ GNUNET_PQ_query_param_absolute_time (&end_date),
+ GNUNET_PQ_query_param_auto_from_type (master_sig),
+ GNUNET_PQ_query_param_end
+ };
+
+ /* no preflight check here, run in its own transaction by the caller */
+ check_connection (pg);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Storing wire fee for %s starting at %s of %s\n",
+ TALER_B2S (master_pub),
+ GNUNET_STRINGS_absolute_time_to_string (start_date),
+ TALER_amount2s (wire_fee));
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "insert_wire_fee",
+ params);
+}
+
+
/* ********************* OLD API ************************** */
/**
@@ -3884,58 +3933,6 @@ postgres_get_authorized_tip_amount (void *cls,
}
-/**
- * Store information about wire fees charged by an exchange,
- * including signature (so we have proof).
- *
- * @param cls closure
- * @paramm exchange_pub public key of the exchange
- * @param h_wire_method hash of wire method
- * @param wire_fee wire fee charged
- * @param closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
- * @param start_date start of fee being used
- * @param end_date end of fee being used
- * @param exchange_sig signature of exchange over fee structure
- * @return transaction status code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_store_wire_fee_by_exchange (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct GNUNET_HashCode *h_wire_method,
- const struct TALER_Amount *wire_fee,
- const struct TALER_Amount *closing_fee,
- struct GNUNET_TIME_Absolute start_date,
- struct GNUNET_TIME_Absolute end_date,
- const struct
- TALER_MasterSignatureP *master_sig)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_auto_from_type (h_wire_method),
- TALER_PQ_query_param_amount (wire_fee),
- TALER_PQ_query_param_amount (closing_fee),
- GNUNET_PQ_query_param_absolute_time (&start_date),
- GNUNET_PQ_query_param_absolute_time (&end_date),
- GNUNET_PQ_query_param_auto_from_type (master_sig),
- GNUNET_PQ_query_param_end
- };
-
- /* no preflight check here, run in its own transaction by the caller */
- check_connection (pg);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Storing wire fee for %s starting at %s of %s\n",
- TALER_B2S (master_pub),
- GNUNET_STRINGS_absolute_time_to_string (start_date),
- TALER_amount2s (wire_fee));
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_wire_fee",
- params);
-}
-
-
/**
* Lookup proof information about a wire transfer.
*
@@ -6303,6 +6300,21 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" ORDER BY credit_serial DESC"
" LIMIT $3",
3),
+ /* For postgres_store_wire_fee_by_exchange() */
+ GNUNET_PQ_make_prepare ("insert_wire_fee",
+ "INSERT INTO merchant_exchange_wire_fees"
+ "(master_pub"
+ ",h_wire_method"
+ ",wire_fee_val"
+ ",wire_fee_frac"
+ ",closing_fee_val"
+ ",closing_fee_frac"
+ ",start_date"
+ ",end_date"
+ ",master_sig)"
+ " VALUES "
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
+ 9),
/* OLD API: */
#if 0
@@ -6326,20 +6338,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" VALUES "
"($1, $2, $3, $4, $5)",
5),
- GNUNET_PQ_make_prepare ("insert_wire_fee",
- "INSERT INTO exchange_wire_fees"
- "(exchange_pub"
- ",h_wire_method"
- ",wire_fee_val"
- ",wire_fee_frac"
- ",closing_fee_val"
- ",closing_fee_frac"
- ",start_date"
- ",end_date"
- ",exchange_sig)"
- " VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
- 9),
GNUNET_PQ_make_prepare ("find_contract_terms_from_hash",
"SELECT"
" contract_terms"
diff --git a/src/lib/merchant_api_post_orders.c
b/src/lib/merchant_api_post_orders.c
index 19dbdb4..7c4d513 100644
--- a/src/lib/merchant_api_post_orders.c
+++ b/src/lib/merchant_api_post_orders.c
@@ -235,7 +235,9 @@ TALER_MERCHANT_orders_post2 (
po->ctx = ctx;
po->cb = cb;
po->cb_cls = cb_cls;
- po->url = TALER_url_join (backend_url, "orders", NULL);
+ po->url = TALER_url_join (backend_url,
+ "private/orders",
+ NULL);
req = json_pack ("{s:O}",
"order", (json_t *) order);
GNUNET_assert (NULL != req);
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index b8a471a..ce181d1 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -42,7 +42,7 @@
*/
#define CONFIG_FILE "test_merchant_api.conf"
-#define PAYTO_I1 "payto://taler-bank/localhost/3"
+#define PAYTO_I1 "payto://x-taler-bank/localhost/3"
/**
* Exchange base URL. Could also be taken from config.
@@ -1037,9 +1037,9 @@ run (void *cls,
merchant_url,
"product-1",
MHD_HTTP_NO_CONTENT),
-#if 0
TALER_TESTING_cmd_batch ("pay",
pay),
+#if 0
TALER_TESTING_cmd_batch ("double-spending",
double_spending),
TALER_TESTING_cmd_batch ("track",
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] 84/277: dce, (continued)
- [taler-merchant] 84/277: dce, gnunet, 2020/07/05
- [taler-merchant] 82/277: implement abort client lib, gnunet, 2020/07/05
- [taler-merchant] 87/277: revise GET /private/orders API, gnunet, 2020/07/05
- [taler-merchant] 86/277: GET /orders/ID API design, gnunet, 2020/07/05
- [taler-merchant] 88/277: fix benchmark FTBFS, gnunet, 2020/07/05
- [taler-merchant] 95/277: db work for POST /transfers, gnunet, 2020/07/05
- [taler-merchant] 96/277: fix FTBFS, gnunet, 2020/07/05
- [taler-merchant] 109/277: commentfix, gnunet, 2020/07/05
- [taler-merchant] 110/277: fix benchmark FTBFS, gnunet, 2020/07/05
- [taler-merchant] 116/277: fix test, gnunet, 2020/07/05
- [taler-merchant] 115/277: misc. fixes,
gnunet <=
- [taler-merchant] 91/277: implement GET /orders/ID, gnunet, 2020/07/05
- [taler-merchant] 101/277: more SQL, gnunet, 2020/07/05
- [taler-merchant] 104/277: GET /transfers implementation, gnunet, 2020/07/05
- [taler-merchant] 102/277: towards idempotency in POST /private/transfers, gnunet, 2020/07/05
- [taler-merchant] 103/277: towards GET /transfers, gnunet, 2020/07/05
- [taler-merchant] 114/277: fix sql, gnunet, 2020/07/05
- [taler-merchant] 119/277: better error handling, gnunet, 2020/07/05
- [taler-merchant] 117/277: get simple pay test to pass, gnunet, 2020/07/05
- [taler-merchant] 94/277: fix ftbfs, gnunet, 2020/07/05
- [taler-merchant] 98/277: implement POST /transfers, gnunet, 2020/07/05