[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 208/277: implement missing SQL
From: |
gnunet |
Subject: |
[taler-merchant] 208/277: implement missing SQL |
Date: |
Sun, 05 Jul 2020 20:52:01 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit 573ee18c1c3c2be680f5ee16058e1ccb26bfe6a8
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jun 13 16:40:34 2020 +0200
implement missing SQL
---
.../taler-merchant-httpd_private-get-orders-ID.c | 12 ++--
src/backenddb/Makefile.am | 3 +-
src/backenddb/plugin_merchantdb_postgres.c | 70 ++++++++++++++++++----
src/include/taler_merchantdb_plugin.h | 7 +--
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 336d83f..63b7148 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 bec76cc..d7eca44 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 a6c1041..db9e9c5 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 2f79674..e8c7154 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
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] 187/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, (continued)
- [taler-merchant] 187/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, gnunet, 2020/07/05
- [taler-merchant] 190/277: implementation of GET /private/tips, gnunet, 2020/07/05
- [taler-merchant] 191/277: test/fix for POST /private/reserves, gnunet, 2020/07/05
- [taler-merchant] 193/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, gnunet, 2020/07/05
- [taler-merchant] 198/277: enable handler, gnunet, 2020/07/05
- [taler-merchant] 200/277: test with MHD error, gnunet, 2020/07/05
- [taler-merchant] 201/277: fix crash, gnunet, 2020/07/05
- [taler-merchant] 205/277: fixed authorize tip and tests for GET /private/tips, gnunet, 2020/07/05
- [taler-merchant] 203/277: sync, gnunet, 2020/07/05
- [taler-merchant] 188/277: private-get-orders-ID now compiles -- but not more than that, gnunet, 2020/07/05
- [taler-merchant] 208/277: implement missing SQL,
gnunet <=
- [taler-merchant] 211/277: adjust API to current spec, gnunet, 2020/07/05
- [taler-merchant] 215/277: this was done by Jonathan, gnunet, 2020/07/05
- [taler-merchant] 213/277: starting with merchant_api_merchant_get_order.c, gnunet, 2020/07/05
- [taler-merchant] 218/277: allow refund_delay to be specified with POST /orders, fix FTBFS, gnunet, 2020/07/05
- [taler-merchant] 216/277: clean up logic: use new EXCHANGE_YNA enum, avoid crazy macro construction to build URLs, use full power of TALER_url_join() instead, gnunet, 2020/07/05
- [taler-merchant] 219/277: tests for new db methods, gnunet, 2020/07/05
- [taler-merchant] 204/277: moved yna to exchange, gnunet, 2020/07/05
- [taler-merchant] 214/277: add logic to parse refund details, gnunet, 2020/07/05
- [taler-merchant] 212/277: adjust GET /orders/ID to match spec, gnunet, 2020/07/05
- [taler-merchant] 217/277: implement merchant_api_merchant_get_order.c, gnunet, 2020/07/05