gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated: return amount_left


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: return amount_left of tip to wallet
Date: Fri, 30 Aug 2019 14:41:59 +0200

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 87f78ab  return amount_left of tip to wallet
87f78ab is described below

commit 87f78ab077166b90d087f69219db9c24dd5569ce
Author: Florian Dold <address@hidden>
AuthorDate: Fri Aug 30 14:41:56 2019 +0200

    return amount_left of tip to wallet
---
 src/backend/taler-merchant-httpd_tip-pickup.c |  8 ++++++--
 src/backend/taler-merchant-httpd_tip-pickup.h | 20 +++++++++++++++++++-
 src/backenddb/plugin_merchantdb_postgres.c    |  9 +++++++++
 src/backenddb/test_merchantdb.c               |  2 +-
 src/include/taler_merchantdb_plugin.h         |  2 ++
 5 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c 
b/src/backend/taler-merchant-httpd_tip-pickup.c
index 9d72b81..3d26c63 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.c
+++ b/src/backend/taler-merchant-httpd_tip-pickup.c
@@ -399,7 +399,7 @@ prepare_pickup (struct PickupContext *pc)
   qs = db->lookup_tip_by_id (db->cls,
                              &pc->tip_id,
                              &pc->exchange_url,
-                             NULL, NULL, NULL);
+                             NULL, NULL, NULL, NULL);
   if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
   {
     unsigned int response_code;
@@ -624,6 +624,7 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
   json_t *extra;
   struct GNUNET_HashCode tip_id;
   struct TALER_Amount tip_amount;
+  struct TALER_Amount tip_amount_left;
   int ret;
   int qs;
 
@@ -665,7 +666,9 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
                              &tip_id,
                              &exchange_url,
                              &extra,
-                             &tip_amount, NULL);
+                             &tip_amount,
+                             &tip_amount_left,
+                             NULL);
 
   if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
   {
@@ -702,6 +705,7 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
                                       "{s:s, s:o}",
                                       "exchange_url", exchange_url,
                                       "amount", TALER_JSON_from_amount 
(&tip_amount),
+                                      "amount_left", TALER_JSON_from_amount 
(&tip_amount_left),
                                       "extra", extra);
 
   GNUNET_free (exchange_url);
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.h 
b/src/backend/taler-merchant-httpd_tip-pickup.h
index da42eaa..181725a 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.h
+++ b/src/backend/taler-merchant-httpd_tip-pickup.h
@@ -24,7 +24,7 @@
 #include "taler-merchant-httpd.h"
 
 /**
- * Manages a /tip-pickup call, checking that the tip is authorized,
+ * Manages a POST /tip-pickup call, checking that the tip is authorized,
  * and if so, returning the withdrawal permissions.
  *
  * @param rh context of the handler
@@ -41,4 +41,22 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh,
                        const char *upload_data,
                        size_t *upload_data_size);
 
+/**
+ * Manages a GET /tip-pickup call.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @return MHD result code
+ */
+int
+MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
+                           struct MHD_Connection *connection,
+                           void **connection_cls,
+                           const char *upload_data,
+                           size_t *upload_data_size);
+
+
 #endif
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 2b2c016..961bac2 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -668,6 +668,8 @@ postgres_initialize (void *cls)
                             ",timestamp"
                             ",amount_val"
                             ",amount_frac"
+                            ",left_val"
+                            ",left_frac"
                             " FROM merchant_tips"
                             " WHERE tip_id=$1",
                             1),
@@ -3343,6 +3345,7 @@ postgres_authorize_tip_TR (void *cls,
  * @param[out] exchange_url set to the URL of the exchange (unless NULL)
  * @param[out] extra extra data to pass to the wallet (unless NULL)
  * @param[out] amount set to the authorized amount (unless NULL)
+ * @param[out] amount_left set to the amount left (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
@@ -3354,12 +3357,14 @@ postgres_lookup_tip_by_id (void *cls,
                            char **exchange_url,
                            json_t **extra,
                            struct TALER_Amount *amount,
+                           struct TALER_Amount *amount_left,
                            struct GNUNET_TIME_Absolute *timestamp)
 {
   struct PostgresClosure *pg = cls;
   char *res_exchange_url;
   json_t *res_extra;
   struct TALER_Amount res_amount;
+  struct TALER_Amount res_amount_left;
   struct GNUNET_TIME_Absolute res_timestamp;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (tip_id),
@@ -3374,6 +3379,8 @@ postgres_lookup_tip_by_id (void *cls,
                                &res_extra),
     TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
                                  &res_amount),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("left",
+                                 &res_amount_left),
     GNUNET_PQ_result_spec_end
   };
   enum GNUNET_DB_QueryStatus qs;
@@ -3392,6 +3399,8 @@ postgres_lookup_tip_by_id (void *cls,
     *exchange_url = strdup (res_exchange_url);
   if (NULL != amount)
     *amount = res_amount;
+  if (NULL != amount_left)
+    *amount_left = res_amount_left;
   if (NULL != timestamp)
     *timestamp = res_timestamp;
   if (NULL != extra)
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 89732f5..84a100c 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -612,7 +612,7 @@ test_tipping ()
       plugin->lookup_tip_by_id (plugin->cls,
                                      &tip_id,
                                      &url,
-                                      NULL, NULL, NULL))
+                                      NULL, NULL, 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 c7009ad..04fb266 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -753,6 +753,7 @@ struct TALER_MERCHANTDB_Plugin
    * @param[out] exchange_url set to the URL of the exchange (unless NULL)
    * @param[out] extra extra data to pass to the wallet
    * @param[out] amount set to the authorized amount (unless NULL)
+   * @param[out] amount_left set to the amount left (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
@@ -764,6 +765,7 @@ struct TALER_MERCHANTDB_Plugin
                       char **exchange_url,
                       json_t **extra,
                       struct TALER_Amount *amount,
+                      struct TALER_Amount *amount_left,
                       struct GNUNET_TIME_Absolute *timestamp);
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]