summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-06-13 16:40:34 +0200
committerChristian Grothoff <christian@grothoff.org>2020-06-13 16:40:34 +0200
commit573ee18c1c3c2be680f5ee16058e1ccb26bfe6a8 (patch)
treedb614a288d2427a8208e08e4456fd55de8471512
parent2f853bebd269b51536bc357c9ae76d5aa24b9d3a (diff)
downloadmerchant-573ee18c1c3c2be680f5ee16058e1ccb26bfe6a8.tar.gz
merchant-573ee18c1c3c2be680f5ee16058e1ccb26bfe6a8.tar.bz2
merchant-573ee18c1c3c2be680f5ee16058e1ccb26bfe6a8.zip
implement missing SQL
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c12
-rw-r--r--src/backenddb/Makefile.am3
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c70
-rw-r--r--src/include/taler_merchantdb_plugin.h7
4 files changed, 67 insertions, 25 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index 336d83fa..63b7148f 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -678,11 +678,9 @@ process_refunds_cb (void *cls,
* the response.
*
* @param cls a `struct GetOrderRequestContext`
- * @param wtid wire transfer subject of the wire transfer for the coin,
- * or NULL if transfer is yet to be made
+ * @param wtid wire transfer subject of the wire transfer for the coin
* @param exchange_url base URL of the exchange that made the payment
- * @param execution_time when was the payment made (or in the future,
- * when is it expected to be made)
+ * @param execution_time when was the payment made
* @param deposit_value contribution of the coin to the total wire transfer value
* @param deposit_fee deposit fee charged by the exchange for the coin
* @param transfer_confirmed did the merchant confirm that a wire transfer with
@@ -708,11 +706,9 @@ process_transfer_details (void *cls,
GNUNET_assert (0 ==
json_array_append_new (
wire_details,
- json_pack ("{s:o?, s:s, s:o, s:o, s:b}",
+ json_pack ("{s:o, s:s, s:o, s:o, s:b}",
"wtid",
- (NULL != wtid)
- ? GNUNET_JSON_from_data_auto (wtid)
- : NULL,
+ GNUNET_JSON_from_data_auto (wtid),
"exchange_url",
exchange_url,
"amount",
diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am
index bec76cc7..d7eca447 100644
--- a/src/backenddb/Makefile.am
+++ b/src/backenddb/Makefile.am
@@ -69,9 +69,10 @@ test_merchantdb_postgres_SOURCES = \
test_merchantdb.c
test_merchantdb_postgres_LDFLAGS = \
- -lgnunetutil \
-ltalerutil \
-ltalerjson \
+ -lgnunetjson \
+ -lgnunetutil \
-ljansson
test_merchantdb_postgres_LDADD = \
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index a6c10413..db9e9c51 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2259,9 +2259,9 @@ lookup_transfer_details_by_order_cb (void *cls,
&exchange_url),
GNUNET_PQ_result_spec_auto_from_type ("wtid",
&wtid),
- TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_value",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_value",
&deposit_value),
- TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_fee",
&deposit_fee),
GNUNET_PQ_result_spec_auto_from_type ("transfer_confirmed",
&transfer_confirmed),
@@ -2348,11 +2348,11 @@ postgres_insert_deposit_to_transfer (
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&deposit_serial),
- GNUNET_PQ_query_param_auto_from_type (&dd->exchange_pub),
+ TALER_PQ_query_param_amount (&dd->coin_contribution),
+ GNUNET_PQ_query_param_absolute_time (&dd->execution_time),
GNUNET_PQ_query_param_auto_from_type (&dd->exchange_sig),
+ GNUNET_PQ_query_param_auto_from_type (&dd->exchange_pub),
GNUNET_PQ_query_param_auto_from_type (&dd->wtid),
- GNUNET_PQ_query_param_absolute_time (&dd->execution_time),
- TALER_PQ_query_param_amount (&dd->coin_contribution),
GNUNET_PQ_query_param_end
};
@@ -6935,6 +6935,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" FROM merchant_contract_terms"
" WHERE order_serial=$1",
1),
+ /* for postgres_lookup_payment_status() */
GNUNET_PQ_make_prepare ("lookup_payment_status_session_id",
"SELECT"
" wired"
@@ -6944,14 +6945,61 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" AND session_id=$2",
2),
/* for postgres_lookup_deposits_by_order() */
- // FIXME
- /* for postgres_lookup_transfer_deposits_by_order() */
- // FIXME
+ GNUNET_PQ_make_prepare ("lookup_deposits_by_order",
+ "SELECT"
+ " deposit_serial"
+ ",exchange_url"
+ ",h_wire"
+ ",amount_with_fee_val"
+ ",amount_with_fee_frac"
+ ",deposit_fee_val"
+ ",deposit_fee_frac"
+ ",coin_pub"
+ " FROM merchant_deposits"
+ " JOIN merchant_accounts USING (account_serial)"
+ " WHERE order_serial=$1",
+ 1),
+ /* for postgres_lookup_transfer_details_by_order() */
+ GNUNET_PQ_make_prepare ("lookup_transfer_details_by_order",
+ "SELECT"
+ " md.deposit_serial"
+ ",md.exchange_url"
+ ",mt.wtid"
+ ",exchange_deposit_value_val"
+ ",exchange_deposit_value_frac"
+ ",exchange_deposit_fee_val"
+ ",exchange_deposit_fee_frac"
+ ",mt.confirmed AS transfer_confirmed"
+ " FROM merchant_transfer_to_coin"
+ " JOIN merchant_deposits AS md USING (deposit_serial)"
+ " JOIN merchant_transfers AS mt USING (credit_serial)"
+ " WHERE deposit_serial IN"
+ " (SELECT deposit_serial"
+ " FROM merchant_deposits"
+ " WHERE order_serial=$1)",
+ 1),
/* for postgres_insert_deposit_to_transfer() */
- // FIXME
+ GNUNET_PQ_make_prepare ("insert_deposit_to_transfer",
+ "INSERT INTO merchant_deposit_to_transfer"
+ "(deposit_serial"
+ ",coin_contribution_value_val"
+ ",coin_contribution_value_frac"
+ ",credit_serial"
+ ",execution_time"
+ ",signkey_serial"
+ ",exchange_sig"
+ ") SELECT $1, $2, $3, credit_serial, $4, signkey_serial, $5"
+ " FROM merchant_transfers"
+ " CROSS JOIN merchant_exchange_signing_keys"
+ " WHERE exchange_pub=$6"
+ " AND wtid=$7",
+ 7),
/* for postgres_mark_order_wired() */
- // FIXME
-
+ GNUNET_PQ_make_prepare ("mark_order_wired",
+ "UPDATE merchant_contract_terms SET"
+ " wired=true"
+ " WHERE order_serial=$1",
+ 1),
/* for process_refund_cb() used in postgres_increase_refund() */
GNUNET_PQ_make_prepare ("find_refunds_by_coin",
"SELECT"
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index 2f796747..e8c71546 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -316,14 +316,11 @@ typedef void
/**
* Typically called by `lookup_transfer_details_by_order`.
- * FIXME: not implemented yet!
*
* @param cls closure
- * @param wtid wire transfer subject of the wire transfer for the coin,
- * or NULL if transfer is yet to be made
+ * @param wtid wire transfer subject of the wire transfer for the coin
* @param exchange_url base URL of the exchange that made the payment
- * @param execution_time when was the payment made (or in the future,
- * when is it expected to be made)
+ * @param execution_time when was the payment made
* @param deposit_value contribution of the coin to the total wire transfer value
* @param deposit_fee deposit fee charged by the exchange for the coin
* @param transfer_confirmed did the merchant confirm that a wire transfer with