[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] branch master updated: implement /tip-quer
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] branch master updated: implement /tip-query |
Date: |
Mon, 27 Nov 2017 15:39:49 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new d2db3ad implement /tip-query
d2db3ad is described below
commit d2db3ad776fd7463e84f96ec4960f91d81b6f587
Author: Florian Dold <address@hidden>
AuthorDate: Mon Nov 27 15:39:31 2017 +0100
implement /tip-query
---
src/backend/Makefile.am | 1 +
src/backend/taler-merchant-httpd.c | 4 +++
src/backend/taler-merchant-httpd_tip-pickup.c | 7 +++--
src/backenddb/plugin_merchantdb_postgres.c | 44 +++++++++++++++++++++------
src/backenddb/test_merchantdb.c | 5 +--
src/include/taler_merchantdb_plugin.h | 14 ++++++---
6 files changed, 55 insertions(+), 20 deletions(-)
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 28212db..c73c7e6 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -25,6 +25,7 @@ taler_merchant_httpd_SOURCES = \
taler-merchant-httpd_tip-authorize.c taler-merchant-httpd_tip-authorize.h \
taler-merchant-httpd_tip-enable.c taler-merchant-httpd_tip-enable.h \
taler-merchant-httpd_tip-pickup.c taler-merchant-httpd_tip-pickup.h \
+ taler-merchant-httpd_tip-query.c taler-merchant-httpd_tip-query.h \
taler-merchant-httpd_track-transaction.c
taler-merchant-httpd_track-transaction.h \
taler-merchant-httpd_track-transfer.c taler-merchant-httpd_track-transfer.h \
taler-merchant-httpd_refund.c taler-merchant-httpd_refund.h
diff --git a/src/backend/taler-merchant-httpd.c
b/src/backend/taler-merchant-httpd.c
index f53a586..9d394ea 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -42,6 +42,7 @@
#include "taler-merchant-httpd_tip-authorize.h"
#include "taler-merchant-httpd_tip-enable.h"
#include "taler-merchant-httpd_tip-pickup.h"
+#include "taler-merchant-httpd_tip-query.h"
#include "taler-merchant-httpd_history.h"
#include "taler-merchant-httpd_refund.h"
@@ -248,6 +249,9 @@ url_handler (void *cls,
{ "/tip-enable", NULL, "application/json",
"Only POST is allowed", 0,
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED},
+ { "/tip-query", MHD_HTTP_METHOD_GET, "text/plain",
+ NULL, 0,
+ &MH_handler_tip_query, MHD_HTTP_OK},
{NULL, NULL, NULL, NULL, 0, 0 }
};
static struct TMH_RequestHandler h404 =
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c
b/src/backend/taler-merchant-httpd_tip-pickup.c
index 3cb73b4..76bf7ce 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.c
+++ b/src/backend/taler-merchant-httpd_tip-pickup.c
@@ -373,9 +373,10 @@ prepare_pickup (struct PickupContext *pc)
{
enum GNUNET_DB_QueryStatus qs;
- qs = db->lookup_exchange_by_tip (db->cls,
- &pc->tip_id,
- &pc->exchange_uri);
+ qs = db->lookup_tip_by_id (db->cls,
+ &pc->tip_id,
+ &pc->exchange_uri,
+ NULL, NULL);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{
unsigned int response_code;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index 4abbb41..6647a5a 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -584,9 +584,13 @@ postgres_initialize (void *cls)
" WHERE pickup_id=$1"
" AND tip_id=$2",
2),
- GNUNET_PQ_make_prepare ("find_exchange_by_tip",
+ GNUNET_PQ_make_prepare ("find_tip_by_id",
"SELECT"
" exchange_uri"
+ ",timestamp"
+ ",amount_val"
+ ",amount_frac"
+ ",amount_curr"
" FROM merchant_tips"
" WHERE tip_id=$1",
1),
@@ -2913,20 +2917,28 @@ postgres_authorize_tip (void *cls,
/**
- * Find out which exchange was associated with @a tip_id
+ * Find out tip authorization details associated with @a tip_id
*
* @param cls closure, typically a connection to the d
* @param tip_id the unique ID for the tip
- * @param[out] exchange_uri set to the URI of the exchange
+ * @param[out] exchange_uri set to the URI of the exchange (unless NULL)
+ * @param[out] amount set to the authorized amount (unless NULL)
+ * @param[out] timestamp set to the timestamp of the tip authorization (unless
NULL)
* @return transaction status, usually
* #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
* #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a credit_uuid already known
*/
static enum GNUNET_DB_QueryStatus
-postgres_lookup_exchange_by_tip (void *cls,
- const struct GNUNET_HashCode *tip_id,
- char **exchange_uri)
+postgres_lookup_tip_by_id (void *cls,
+ const struct GNUNET_HashCode *tip_id,
+ char **exchange_uri,
+ struct TALER_Amount *amount,
+ struct GNUNET_TIME_Absolute *timestamp)
{
+ char *res_exchange_uri;
+ struct TALER_Amount res_amount;
+ struct GNUNET_TIME_Absolute res_timestamp;
+
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (tip_id),
@@ -2934,20 +2946,32 @@ postgres_lookup_exchange_by_tip (void *cls,
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("exchange_uri",
- exchange_uri),
+ &res_exchange_uri),
+ GNUNET_PQ_result_spec_absolute_time ("timestamp",
+ &res_timestamp),
+ TALER_PQ_result_spec_amount ("amount",
+ &res_amount),
GNUNET_PQ_result_spec_end
};
enum GNUNET_DB_QueryStatus qs;
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "find_exchange_by_tip",
+ "find_tip_by_id",
params,
rs);
if (0 >= qs)
{
- *exchange_uri = NULL;
+ if (NULL != exchange_uri)
+ *exchange_uri = NULL;
return qs;
}
+ if (NULL != exchange_uri)
+ *exchange_uri = strdup (res_exchange_uri);
+ if (NULL != amount)
+ *amount = res_amount;
+ if (NULL != timestamp)
+ *timestamp = res_timestamp;
+ GNUNET_PQ_cleanup_result (rs);
return qs;
}
@@ -3209,7 +3233,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->mark_proposal_paid = &postgres_mark_proposal_paid;
plugin->enable_tip_reserve = &postgres_enable_tip_reserve;
plugin->authorize_tip = &postgres_authorize_tip;
- plugin->lookup_exchange_by_tip = &postgres_lookup_exchange_by_tip;
+ plugin->lookup_tip_by_id = &postgres_lookup_tip_by_id;
plugin->pickup_tip = &postgres_pickup_tip;
plugin->start = postgres_start;
plugin->commit = postgres_commit;
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 78e72e3..62a6c5e 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -638,9 +638,10 @@ test_tipping ()
return GNUNET_SYSERR;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->lookup_exchange_by_tip (plugin->cls,
+ plugin->lookup_tip_by_id (plugin->cls,
&tip_id,
- &uri))
+ &uri,
+ NULL, NULL))
{
GNUNET_break (0);
return GNUNET_SYSERR;
diff --git a/src/include/taler_merchantdb_plugin.h
b/src/include/taler_merchantdb_plugin.h
index 2093a49..b36a04e 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -685,19 +685,23 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Find out which exchange was associated with @a tip_id
+ * Find out tip authorization details associated with @a tip_id
*
* @param cls closure, typically a connection to the d
* @param tip_id the unique ID for the tip
- * @param[out] exchange_uri set to the URI of the exchange
+ * @param[out] exchange_uri set to the URI of the exchange (unless NULL)
+ * @param[out] amount set to the authorized amount (unless NULL)
+ * @param[out] timestamp set to the timestamp of the tip authorization
(unless NULL)
* @return transaction status, usually
* #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
* #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a credit_uuid already known
*/
enum GNUNET_DB_QueryStatus
- (*lookup_exchange_by_tip)(void *cls,
- const struct GNUNET_HashCode *tip_id,
- char **exchange_uri);
+ (*lookup_tip_by_id)(void *cls,
+ const struct GNUNET_HashCode *tip_id,
+ char **exchange_uri,
+ struct TALER_Amount *amount,
+ struct GNUNET_TIME_Absolute *timestamp);
/**
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant] branch master updated: implement /tip-query,
gnunet <=