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 (6520fde -> b98a6a4)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (6520fde -> b98a6a4)
Date: Wed, 14 Jun 2017 09:57:24 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository merchant.

    from 6520fde  backend /refund handler skeleton, not in compilation
     new 4d16ae5  add refund header file
     new b98a6a4  refund table takes merchant public key too

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/version.texi                                   |  4 +--
 src/backend/Makefile.am                            |  3 +-
 src/backend/taler-merchant-httpd.c                 |  2 +-
 src/backend/taler-merchant-httpd_refund.c          |  3 +-
 ...t-httpd_map.h => taler-merchant-httpd_refund.h} | 42 ++++++++++------------
 src/backenddb/plugin_merchantdb_postgres.c         | 28 ++++++++++++---
 src/backenddb/test_merchantdb.c                    |  1 +
 src/include/taler_merchantdb_plugin.h              |  8 +++--
 8 files changed, 55 insertions(+), 36 deletions(-)
 rename src/backend/{taler-merchant-httpd_map.h => 
taler-merchant-httpd_refund.h} (60%)

diff --git a/doc/version.texi b/doc/version.texi
index fc2400a..acbfcb4 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
address@hidden UPDATED 7 June 2017
address@hidden UPDATED-MONTH June 2017
address@hidden UPDATED 31 May 2017
address@hidden UPDATED-MONTH May 2017
 @set EDITION 0.3.0
 @set VERSION 0.3.0
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 55ad752..1233ba8 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -24,7 +24,8 @@ taler_merchant_httpd_SOURCES = \
   taler-merchant-httpd_pay.c taler-merchant-httpd_pay.h \
   taler-merchant-httpd_history.c taler-merchant-httpd_history.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_track-transfer.c taler-merchant-httpd_track-transfer.h \
+  taler-merchant-httpd_refund.c taler-merchant-httpd_refund.h
 
 
 taler_merchant_httpd_LDADD = \
diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index 0efa7eb..8930c10 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -40,7 +40,7 @@
 #include "taler-merchant-httpd_track-transaction.h"
 #include "taler-merchant-httpd_track-transfer.h"
 #include "taler-merchant-httpd_history.h"
-#include "taler-merchant-httpd_map.h"
+#include "taler-merchant-httpd_refund.h"
 
 /**
  * Backlog for listen operation on unix-domain sockets.
diff --git a/src/backend/taler-merchant-httpd_refund.c 
b/src/backend/taler-merchant-httpd_refund.c
index 53ca0a3..a55eb70 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -157,7 +157,8 @@ MH_handler_refund_lookup (struct TMH_RequestHandler *rh,
                                           TALER_EC_PARAMETER_MISSING,
                                            "order_id");
   /* FIXME: TBD */
-  return res;
+
+  /* return res; */
 }
 
 
diff --git a/src/backend/taler-merchant-httpd_map.h 
b/src/backend/taler-merchant-httpd_refund.h
similarity index 60%
rename from src/backend/taler-merchant-httpd_map.h
rename to src/backend/taler-merchant-httpd_refund.h
index 83aca2b..64da3f9 100644
--- a/src/backend/taler-merchant-httpd_map.h
+++ b/src/backend/taler-merchant-httpd_refund.h
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  (C) 2014, 2015, 2016 INRIA
+  (C) 2014, 2015, 2016, 2017 INRIA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
@@ -13,23 +13,22 @@
   You should have received a copy of the GNU General Public License along with
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
+
 /**
- * @file backend/taler-merchant-httpd_map.c
+ * @file backend/taler-merchant-httpd_refund.c
  * @brief HTTP serving layer mainly intended to communicate with the frontend
  * @author Marcello Stanisci
  */
 
-#ifndef TALER_MERCHANT_HTTPD_MAP_H
-#define TALER_MERCHANT_HTTPD_MAP_H
+#ifndef TALER_MERCHANT_HTTPD_REFUND_H
+#define TALER_MERCHANT_HTTPD_REFUND_H
 #include <microhttpd.h>
 #include "taler-merchant-httpd.h"
 
-
 /**
- * Manage a /map/in request. Store in db a plain text contract
- * and its hashcode.
+ * Handle request for increasing the refund associated with
+ * a contract.
  *
- * @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
@@ -37,16 +36,15 @@
  * @return MHD result code
  */
 int
-MH_handler_map_in (struct TMH_RequestHandler *rh,
-                   struct MHD_Connection *connection,
-                   void **connection_cls,
-                   const char *upload_data,
-                   size_t *upload_data_size);
+MH_handler_refund_increase (struct TMH_RequestHandler *rh,
+                            struct MHD_Connection *connection,
+                            void **connection_cls,
+                            const char *upload_data,
+                            size_t *upload_data_size);
 
 
 /**
- * Manage a /map/out request. Query the db and returns a plain
- * text contract associated with the hashcode given as input
+ * Return refund situation about a contract.
  *
  * @param rh context of the handler
  * @param connection the MHD connection to handle
@@ -56,11 +54,9 @@ MH_handler_map_in (struct TMH_RequestHandler *rh,
  * @return MHD result code
  */
 int
-MH_handler_map_out (struct TMH_RequestHandler *rh,
-                    struct MHD_Connection *connection,
-                    void **connection_cls,
-                    const char *upload_data,
-                    size_t *upload_data_size);
-
-/* end of taler-merchant-httpd_history.c */
-#endif
+MH_handler_refund_lookup (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 d51f401..3335051 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -238,6 +238,7 @@ postgres_initialize (void *cls)
                             ");"),
     GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_refunds ("
                             " rtransaction_id BIGSERIAL"
+                            ",merchant_pub BYTEA NOT NULL CHECK 
(LENGTH(merchant_pub)=32)"
                             ",h_contract_terms BYTEA NOT NULL"
                             ",coin_pub BYTEA NOT NULL CHECK 
(LENGTH(coin_pub)=32)"
                             ",reason VARCHAR NOT NULL"
@@ -340,14 +341,15 @@ postgres_initialize (void *cls)
                             3),
     GNUNET_PQ_make_prepare ("insert_refund",
                             "INSERT INTO merchant_refunds"
-                            "(h_contract_terms"
+                            "(merchant_pub"
+                            ",h_contract_terms"
                             ",coin_pub"
                             ",reason"
                             ",refund_amount_val"
                             ",refund_amount_frac"
                             ",refund_amount_curr) VALUES"
-                            "($1, $2, $3, $4, $5, $6)",
-                            6),
+                            "($1, $2, $3, $4, $5, $6, $7)",
+                            7),
     GNUNET_PQ_make_prepare ("insert_proof",
                             "INSERT INTO merchant_proofs"
                             "(exchange_uri"
@@ -410,8 +412,9 @@ postgres_initialize (void *cls)
                             3),
     GNUNET_PQ_make_prepare ("find_refunds_from_contract_terms_hash",
                             "SELECT * FROM merchant_refunds"
-                            " WHERE h_contract_terms=$1",
-                            1),
+                            " WHERE merchant_pub=$1"
+                            " AND h_contract_terms=$2",
+                            2),
     GNUNET_PQ_make_prepare ("find_contract_terms_by_date_and_range",
                             "SELECT"
                             " contract_terms"
@@ -1647,6 +1650,9 @@ postgres_find_deposits_by_wtid (void *cls,
 /**
  * Obtain refunds associated with a contract.
  *
+ * @param cls closure, typically a connection to the db
+ * @param merchant_pub public key of the merchant instance
+ * @param h_contract_terms hash code of the contract
  * @param rc function to call for each coin on which there is a refund
  * @param rc_cls closure for @a rc
  * @return #GNUNET_OK if we called @a rc on all coins
@@ -1655,6 +1661,7 @@ postgres_find_deposits_by_wtid (void *cls,
  */
 int
 postgres_get_refunds_from_contract_terms_hash (void *cls,
+                                               const struct 
TALER_MerchantPublicKeyP *merchant_pub,
                                                const struct GNUNET_HashCode 
*h_contract_terms,
                                                TALER_MERCHANTDB_RefundCallback 
rc,
                                                void *rc_cls)
@@ -1665,6 +1672,7 @@ postgres_get_refunds_from_contract_terms_hash (void *cls,
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
     GNUNET_PQ_query_param_end
   };
@@ -1805,6 +1813,11 @@ struct InsertRefundContext
   struct TALER_Amount *refund;
 
   /**
+   * Merchant instance public key
+   */
+  const struct TALER_MerchantPublicKeyP *merchant_pub;
+
+  /**
    * Hash code representing the contract
    */
   const struct GNUNET_HashCode *h_contract_terms;
@@ -1821,6 +1834,7 @@ struct InsertRefundContext
  * in the db API.
  *
  * @param cls closure, tipically a connection to the db
+ * @param merchant_pub merchant instance public key
  * @param h_contract_terms hashcode of the contract related to this refund
  * @param coin_pub public key of the coin giving the (part of) refund
  * @param reason human readable explaination behind the refund
@@ -1828,6 +1842,7 @@ struct InsertRefundContext
  */
 enum GNUNET_DB_QueryStatus
 insert_refund (void *cls,
+               const struct TALER_MerchantPublicKeyP *merchant_pub,
                const struct GNUNET_HashCode *h_contract_terms,
                const struct TALER_CoinSpendPublicKeyP *coin_pub,
                const char *reason,
@@ -1836,6 +1851,7 @@ insert_refund (void *cls,
   struct PostgresClosure *pg = cls;
   
   struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     GNUNET_PQ_query_param_string (reason),
@@ -2005,6 +2021,7 @@ process_deposits_cb (void *cls,
     if ( (0 != small->value) || (0 != small->fraction) )
       if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
             insert_refund (ctx->pg,
+                           ctx->merchant_pub,
                            ctx->h_contract_terms,
                            &coin_pub,
                            ctx->reason,
@@ -2132,6 +2149,7 @@ postgres_increase_refund_for_contract (void *cls,
   ctx.refund = &_refund;
   ctx.reason = reason;
   ctx.h_contract_terms = h_contract_terms;
+  ctx.merchant_pub = merchant_pub;
 
   ret = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
                                               "find_deposits",
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 0c9b455..975b3b4 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -565,6 +565,7 @@ run (void *cls)
                                       NULL));
   FAILIF (GNUNET_NO !=
           plugin->get_refunds_from_contract_terms_hash (plugin->cls,
+                                                        &merchant_pub,
                                                         &h_contract_terms,
                                                         &refund_cb,
                                                         NULL));
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index e4ff082..2cef794 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -529,6 +529,7 @@ struct TALER_MERCHANTDB_Plugin
    * increase the refund on an existing contract.
    *
    * @param cls closure
+   * @param merchant_pub merchant's instance public key
    * @param h_contract_terms
    * @param merchant_pub merchant's instance public key
    * @param refund maximum refund to return to the customer for this contract
@@ -550,6 +551,9 @@ struct TALER_MERCHANTDB_Plugin
   /**
    * Obtain refunds associated with a contract.
    *
+   * @param cls closure, typically a connection to the db
+   * @param merchant_pub public key of the merchant instance
+   * @param h_contract_terms hash code of the contract
    * @param rc function to call for each coin on which there is a refund
    * @param rc_cls closure for @a rc
    * @return #GNUNET_OK if we called @a rc on all coins
@@ -558,12 +562,10 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*get_refunds_from_contract_terms_hash)(void *cls,
+                                          const struct 
TALER_MerchantPublicKeyP *merchant_pub,
                                           const struct GNUNET_HashCode 
*h_contract_terms,
                                           TALER_MERCHANTDB_RefundCallback rc,
                                           void *rc_cls);
-
-
 };
 
-
 #endif

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



reply via email to

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